| Task: | Cent saving |
| Sender: | ContinuedLife |
| Submission time: | 2016-05-28 13:44:58 +0300 |
| Language: | C++ |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.06 s | details |
| #2 | WRONG ANSWER | 0.06 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:50:55: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0; j< min(stack_1.size(), stack_4.size()); j++){
^
input/code.cpp:54:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0; j<stack_4.size(); j++){
^Code
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(6);
using namespace std;
int main(){ _
int TC; cin >> TC;
while(TC--){
int n, num; cin >> n;
stack<int> stack_1;
stack<int> stack_3;
stack<int> stack_4;
int res = 0;
for(int i = 0; i < n; ++i){
cin >> num;
switch(num % 5){
case 0:
res+=num; break;
case 1:
stack_1.push(num); break;
case 2: res+=num-2; break;
case 3:
if(!stack_4.empty()){
res += stack_4.top(); stack_4.pop();
res += num - 2;
} else {
stack_3.push(num);
}
break;
case 4:
if(!stack_3.empty()){
res += stack_3.top() + num - 2; stack_3.pop();
} else {
stack_4.push(num);
}
break;
}
if(!stack_4.empty()){
int j = stack_4.size()/3;
for(int k=0; k<j; k++){
res += stack_4.top();
stack_4.pop();
res += stack_4.top();
stack_4.pop();
res += stack_4.top();
stack_4.pop();
res -= 2;
}
for(int j=0; j< min(stack_1.size(), stack_4.size()); j++){
res += stack_4.top(); stack_4.pop();
res += stack_1.top(); stack_1.pop();
}
for(int j=0; j<stack_4.size(); j++){
res += stack_4.top()+1; stack_4.pop();
}
} else if(!stack_3.empty()){
int j = stack_3.size()/2;
for(int k=0; k<j; k++){
res += stack_3.top();
stack_3.pop();
res += stack_3.top();
stack_3.pop();
res -= 1;
}
if(stack_3.size()>0){
if(stack_1.size() > 1){
res += stack_3.top();
stack_3.pop();
} else if( stack_1.size() > 0) {
res += stack_3.top() + 1;
stack_3.pop();
}
}
}
}
while( stack_1.size()>0){
res += stack_1.top() -1;
stack_1.pop();
}
cout << res << endl;
}
return 0;
}
Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 100 1000 528433894 255789530 559301042 ... |
| correct output |
|---|
| 475191144965 460688647850 478543444030 475238936090 456736521510 ... |
| user output |
|---|
| -1550224312 1127147713 1802074797 -1502433191 1469988748 ... Truncated |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 1 100000 666086355 190481330 514353517 ... |
| correct output |
|---|
| 47176864928795 |
| user output |
|---|
| 944209951 |
