Task: | Kulut |
Sender: | cppbetter |
Submission time: | 2023-01-21 13:36:32 +0200 |
Language: | C++ (C++20) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | WRONG ANSWER | 0.00 s | details |
#3 | WRONG ANSWER | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | WRONG ANSWER | 0.00 s | details |
#7 | WRONG ANSWER | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.00 s | details |
Compiler report
input/code.cpp: In function 'int main()': input/code.cpp:68:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<char, char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare] 68 | for(int i = 0; i < payment.size(); i++) | ~~^~~~~~~~~~~~~~~~
Code
#include <iostream> #include <vector> #include <tuple> int main() { int n; std::cin >> n; int total = 0; int m[4] = {0}; for(int i = 0; i < n; i++) { char p; int d; std::cin >> p >> d; m[p - 'A'] += d; total += d; } int avrg = total / 4; // Pay for the stupid money spenders work... int left[4] = {}; for(int i = 0; i < 4; i++) left[i] = avrg - m[i]; std::vector<std::pair<char, char>> payment; std::vector<int> count; for(int i = 0; i < 4; i++) { // Find someone who has money... till all is payed while(left[i] < 0) { // Find someone who can pay for(int j = 0; j < 4; j++) { if(left[j] > 0) { payment.emplace_back(j + 'A', i + 'A'); if(left[j] + left[i] > 0) { count.emplace_back(std::abs(left[i] )); left[i] = 0; left[j] += left[i]; } else { count.emplace_back(std::abs(left[j])); left[i] += left[j]; left[j] = 0; } break; } } } } std::cout << payment.size() << "\n"; for(int i = 0; i < payment.size(); i++) { std::cout << payment[i].first << " " << payment[i].second << " " << count[i] << "\n"; } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
100 C 224 D 4 D 624 D 64 ... |
correct output |
---|
3 A B 630 C B 1636 C D 1470 |
user output |
---|
3 A B 630 C B 1636 C D 1470 |
Test 2
Verdict: WRONG ANSWER
input |
---|
100 D 768 B 608 A 116 C 80 ... |
correct output |
---|
3 B A 756 B C 1668 D C 1776 |
user output |
---|
3 B A 756 B C 2424 D C 1020 |
Test 3
Verdict: WRONG ANSWER
input |
---|
100 B 184 C 840 D 648 A 876 ... |
correct output |
---|
3 A B 1131 B C 190 C D 297 |
user output |
---|
2 A B 941 A D 297 |
Test 4
Verdict: ACCEPTED
input |
---|
100 C 560 D 664 D 632 C 944 ... |
correct output |
---|
3 B A 3230 C B 2572 D C 1594 |
user output |
---|
3 B A 658 C A 978 D A 1594 |
Test 5
Verdict: ACCEPTED
input |
---|
100 B 20 A 664 D 504 A 248 ... |
correct output |
---|
3 A B 138 B C 652 C D 350 |
user output |
---|
3 A C 138 B C 164 B D 350 |
Test 6
Verdict: WRONG ANSWER
input |
---|
100 B 204 D 520 C 500 C 256 ... |
correct output |
---|
3 B A 285 B C 482 C D 1321 |
user output |
---|
3 B A 285 B D 767 C D 554 |
Test 7
Verdict: WRONG ANSWER
input |
---|
100 B 672 B 840 A 712 C 640 ... |
correct output |
---|
3 B A 324 C B 5128 D C 2920 |
user output |
---|
3 C A 324 C B 2208 D B 2596 |
Test 8
Verdict: ACCEPTED
input |
---|
100 C 860 D 732 A 952 C 940 ... |
correct output |
---|
3 A B 24 C B 536 D C 2252 |
user output |
---|
3 A B 24 D B 536 D C 1716 |
Test 9
Verdict: ACCEPTED
input |
---|
100 C 84 A 592 B 840 C 708 ... |
correct output |
---|
3 A B 115 B C 1746 D C 3791 |
user output |
---|
3 A C 115 B C 1631 D C 3791 |
Test 10
Verdict: ACCEPTED
input |
---|
1 A 100 |
correct output |
---|
3 B A 75 C B 50 D C 25 |
user output |
---|
3 B A 25 C A 25 D A 25 |
Test 11
Verdict: ACCEPTED
input |
---|
4 A 25 B 25 C 25 D 25 |
correct output |
---|
0 |
user output |
---|
0 |