Task: | Cued In |
Sender: | Pietari Kaskela |
Submission time: | 2017-10-31 18:19:58 +0200 |
Language: | C++ |
Status: | READY |
Result: | ACCEPTED |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.04 s | details |
#2 | ACCEPTED | 0.04 s | details |
#3 | ACCEPTED | 0.04 s | details |
#4 | ACCEPTED | 0.05 s | details |
#5 | ACCEPTED | 0.05 s | details |
#6 | ACCEPTED | 0.05 s | details |
#7 | ACCEPTED | 0.03 s | details |
#8 | ACCEPTED | 0.03 s | details |
#9 | ACCEPTED | 0.04 s | details |
#10 | ACCEPTED | 0.04 s | details |
#11 | ACCEPTED | 0.04 s | details |
#12 | ACCEPTED | 0.03 s | details |
#13 | ACCEPTED | 0.03 s | details |
#14 | ACCEPTED | 0.05 s | details |
#15 | ACCEPTED | 0.03 s | details |
#16 | ACCEPTED | 0.03 s | details |
#17 | ACCEPTED | 0.04 s | details |
#18 | ACCEPTED | 0.03 s | details |
Code
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; map<string, int> l; l["red"] = 1; l["yellow"] = 2; l["green"] = 3; l["brown"] = 4; l["blue"] = 5; l["pink"] = 6; l["black"] = 7; int ans = 0; deque<int> p; for(int i = 0; i < n; ++i){ string tmp; cin >> tmp; p.push_back(l[tmp]); } sort(p.begin(), p.end()); int last = p.back(); if(p.front() != 1) p.pop_back(); ans+=last; //cout << "lis " <<ans << endl; while(p.size()){ if(last != 1 && p.front() == 1){ ans++; //cout << "lis " << 1 << endl; p.pop_front(); last = 1; } else{ if(last == 1 && p.back() == 1) break; last = p.back(); ans+=last; //cout << "lis2 " << last << endl; if(p.size() == 0 || p.front() != 1) p.pop_back(); } } cout << ans << '\n'; return 0; }
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 |