CSES - Datatähti 2023 loppu - Results
Submission details
Task:Kulut
Sender:Tipu
Submission time:2023-01-21 13:38:37 +0200
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#30.00 sdetails
#40.00 sdetails
#50.00 sdetails
#60.00 sdetails
#70.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.00 sdetails
#11ACCEPTED0.00 sdetails

Code

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;


// Syöte:
// 4
// A 100
// B 50
// A 50
// D 80
map<string, int> h {{"A", 0},{"B",0}, {"C",0}, {"D",0}};

void p(string a, string b, int c){
    h[a] -= c;
    h[b] += c;
    cout << b << " " << a << " " << c << "\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    

    int n;
    cin >> n;

    int s= 0;




    for (int i = 0; i < n; i++)
    {
        string a;
        cin >> a;
        int b;
        cin >> b;

        s += b;

        h[a] += b;
    }
    s /= 4;

    while(h["A"] > s){
        if(h["B"] < s){
            int c = min(h["A"] - s, s - h["B"]);
            p("A","B",c);
        }
        else if(h["C"] < s){
            int c = min(h["A"] - s, s - h["C"]);
            p("A","C",c);
        }
        else if(h["D"] < s){
            int c = min(h["A"] - s, s - h["D"]);
            p("A","D",c);
        }
    }
    while(h["B"] > s){
        if(h["A"] < s){
            int c = min(h["B"] - s, s - h["A"]);
            p("B","A",c);
        }
        else if(h["C"] < s){
            int c = min(h["B"] - s, s - h["C"]);
            p("B","C",c);
        }
        else if(h["D"] < s){
            int c = min(h["B"] - s, s - h["D"]);
            p("B","D",c);
        }
    }
    while(h["C"] > s){
        if(h["A"] < s){
            int c = min(h["C"] - s, s - h["A"]);
            p("C","A",c);
        }
        else if(h["B"] < s){
            int c = min(h["C"] - s, s - h["B"]);
            p("C","B",c);
        }
        else if(h["D"] < s){
            int c = min(h["C"] - s, s - h["D"]);
            p("C","D",c);
        }
    }
    while(h["D"] > s){
        if(h["A"] < s){
            int c = min(h["D"] - s, s - h["A"]);
            p("D","A",c);
        }
        else if(h["B"] < s){
            int c = min(h["D"] - s, s - h["B"]);
            p("D","B",c);
        }
        else if(h["C"] < s){
            int c = min(h["D"] - s, s - h["C"]);
            p("D","C",c);
        }
    }
}

Test details

Test 1

Verdict:

input
100
C 224
D 4
D 624
D 64
...

correct output
3
A B 630
C B 1636
C D 1470

user output
A B 630
C B 1636
C D 1470

Test 2

Verdict:

input
100
D 768
B 608
A 116
C 80
...

correct output
3
B A 756
B C 1668
D C 1776

user output
B A 756
B C 1668
D C 1776

Test 3

Verdict:

input
100
B 184
C 840
D 648
A 876
...

correct output
3
A B 1131
B C 190
C D 297

user output
A B 941
A D 190
C D 107

Test 4

Verdict:

input
100
C 560
D 664
D 632
C 944
...

correct output
3
B A 3230
C B 2572
D C 1594

user output
B A 658
C A 978
D A 1594

Test 5

Verdict:

input
100
B 20
A 664
D 504
A 248
...

correct output
3
A B 138
B C 652
C D 350

user output
A C 138
B C 164
B D 350

Test 6

Verdict:

input
100
B 204
D 520
C 500
C 256
...

correct output
3
B A 285
B C 482
C D 1321

user output
B A 285
B D 482
C D 839

Test 7

Verdict:

input
100
B 672
B 840
A 712
C 640
...

correct output
3
B A 324
C B 5128
D C 2920

user output
C A 324
C B 1884
D B 2920

Test 8

Verdict:

input
100
C 860
D 732
A 952
C 940
...

correct output
3
A B 24
C B 536
D C 2252

user output
A B 24
D B 536
D C 1716

Test 9

Verdict:

input
100
C 84
A 592
B 840
C 708
...

correct output
3
A B 115
B C 1746
D C 3791

user output
A C 115
B C 1631
D C 3791

Test 10

Verdict:

input
1
A 100

correct output
3
B A 75
C B 50
D C 25

user output
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
(empty)