ALCATRAZ2 - GO GOA GONE
So, it was winter and Me and 8 of my friends decided to plan a trip to GOA. Since the Bars and Clubs are too Expensive out there, we decided to pool money together for our whole trip expenses. Now since every group has some internal politics going on, same applies to our group also :P. 2 Members that are having a cold war between them won't go to the trip if the other one is going. But Since we want to enjoy a lavish party, we want to maximize the pooled money. So, for this task I've chosen my marwari friend Mohit to solve this problem (He's good at money matters). Your task is to help Mohit achieve the maximum pooled money.
Input
First Line will contain 8 space separated integers denoting the money contributed by each member in order.
The next line will contain the total number of pairs having a cold war in between them. Let us denote this by P.
The next P lines will contain 2 numbers separated by a space showing the members having a cold war. Numbers used to denote members will be (1 - 8) for each of the 8 members.
Constraints
Everything is guaranteed to easily fit in 32 bit integer type.
Output
Output will give the maximum amount of money that can be pooled.
Example
Input: 3 14 5 2 3 4 1 9 4 1 2 2 3 4 5 7 8 Output: 30
hide comments
mostafiz_53:
2020-02-06 16:16:26
Can someone explain this output?
|
|
sandeepd:
2020-01-09 21:51:21
All I can say is - thanks for this problem. Thanks a lot. |
|
amanharitsh:
2019-10-27 10:23:08
AC in one go! Bitmasking :) |
|
Amitayush Thakur:
2019-10-06 18:21:12
Some issue with the input file (probably spaces or EOF issue) because of which Python got Runtime error but C++ got accepted. |
|
itssanat:
2019-03-28 12:46:54
AC in one go :P, just use simple logic and common sense :). no need of using any specific algorithm. Last edit: 2019-03-28 12:47:55 |
|
duet_cse16:
2018-12-09 18:28:17
Can anyone explain the problem statement ??
|
|
nitish235:
2018-10-23 09:48:28
submit by selecting c++14(clang4.0) .if you choose other version than you may get compilation error.. I dont know why this is happening..i was also getting compilation error :/
|
|
vikasrathee10:
2018-06-14 15:26:20
How to do it using Recursion?
|
|
holmesherlock:
2017-12-24 11:52:16
simple bitmask |
|
amulyagaur:
2017-12-15 14:26:31
finally removed from todo! |
Added by: | Alcatraz |
Date: | 2016-12-08 |
Time limit: | 0.100s-1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU |
Resource: | Own Problem |