Task: | Cued In |
Sender: | Hannes Ihalainen |
Submission time: | 2017-10-31 17:33:45 +0200 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | ACCEPTED | 0.04 s | details |
#3 | ACCEPTED | 0.04 s | details |
#4 | ACCEPTED | 0.04 s | details |
#5 | ACCEPTED | 0.03 s | details |
#6 | ACCEPTED | 0.05 s | details |
#7 | ACCEPTED | 0.04 s | details |
#8 | ACCEPTED | 0.05 s | details |
#9 | ACCEPTED | 0.06 s | details |
#10 | ACCEPTED | 0.05 s | details |
#11 | ACCEPTED | 0.05 s | details |
#12 | ACCEPTED | 0.04 s | details |
#13 | ACCEPTED | 0.04 s | details |
#14 | ACCEPTED | 0.03 s | details |
#15 | ACCEPTED | 0.05 s | details |
#16 | ACCEPTED | 0.05 s | details |
#17 | ACCEPTED | 0.04 s | details |
#18 | ACCEPTED | 0.04 s | details |
Code
#include <iostream> #include <vector> #include <string> #include <algorithm> int main() { int n; std::cin >> n; std::vector<int> balls; for (int i = 0; i < n; ++i) { std::string str; std::cin >> str; if (str == "red") { balls.push_back(1); } else if (str == "yellow") { balls.push_back(2); } else if (str == "green") { balls.push_back(3); } else if (str == "brown") { balls.push_back(4); } else if (str == "blue") { balls.push_back(5); } else if (str == "pink") { balls.push_back(6); } else { balls.push_back(7); } } std::sort(balls.begin(), balls.end()); if (n == 0) { std::cout << "0\n"; } else if (balls[balls.size() - 1] == 1) { std::cout << "1\n"; } else { int reds = 0; int total = 0; for (int i = 0; i < n; ++i) { if (balls[i] == 1) { ++reds; } else { total += balls[i]; } } total += reds * (1 + balls[balls.size() - 1]); std::cout << total << '\n'; } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
12 brown yellow red black ... |
correct output |
---|
78 |
user output |
---|
78 |
Test 2
Verdict: ACCEPTED
input |
---|
14 red blue red brown ... |
correct output |
---|
96 |
user output |
---|
96 |
Test 3
Verdict: ACCEPTED
input |
---|
3 black pink brown |
correct output |
---|
17 |
user output |
---|
17 |
Test 4
Verdict: ACCEPTED
input |
---|
3 red red red |
correct output |
---|
1 |
user output |
---|
1 |
Test 5
Verdict: ACCEPTED
input |
---|
5 red red green yellow ... |
correct output |
---|
17 |
user output |
---|
17 |
Test 6
Verdict: ACCEPTED
input |
---|
5 black yellow brown pink ... |
correct output |
---|
24 |
user output |
---|
24 |
Test 7
Verdict: ACCEPTED
input |
---|
6 brown green red pink ... |
correct output |
---|
32 |
user output |
---|
32 |
Test 8
Verdict: ACCEPTED
input |
---|
13 blue red red brown ... |
correct output |
---|
83 |
user output |
---|
83 |
Test 9
Verdict: ACCEPTED
input |
---|
15 red red red pink ... |
correct output |
---|
99 |
user output |
---|
99 |
Test 10
Verdict: ACCEPTED
input |
---|
21 red red red red ... |
correct output |
---|
147 |
user output |
---|
147 |
Test 11
Verdict: ACCEPTED
input |
---|
1 black |
correct output |
---|
7 |
user output |
---|
7 |
Test 12
Verdict: ACCEPTED
input |
---|
1 blue |
correct output |
---|
5 |
user output |
---|
5 |
Test 13
Verdict: ACCEPTED
input |
---|
1 brown |
correct output |
---|
4 |
user output |
---|
4 |
Test 14
Verdict: ACCEPTED
input |
---|
6 yellow green brown blue ... |
correct output |
---|
27 |
user output |
---|
27 |
Test 15
Verdict: ACCEPTED
input |
---|
1 green |
correct output |
---|
3 |
user output |
---|
3 |
Test 16
Verdict: ACCEPTED
input |
---|
1 pink |
correct output |
---|
6 |
user output |
---|
6 |
Test 17
Verdict: ACCEPTED
input |
---|
1 red |
correct output |
---|
1 |
user output |
---|
1 |
Test 18
Verdict: ACCEPTED
input |
---|
1 yellow |
correct output |
---|
2 |
user output |
---|
2 |