CSES - Datatähti 2023 loppu - Results
Submission details
Task:Kulut
Sender:adex720
Submission time:2023-01-21 16:37:01 +0200
Language:C++ (C++17)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.00 sdetails
#11ACCEPTED0.00 sdetails

Code

#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    int maksut[4];

    for (int i = 0; i < 4; i++)
    {
        maksut[i] = 0;
    }

    char henkilo;
    int summa;
    int yht = 0;

    int index;
    for (int i = 0; i < n; i++)
    {
        cin >> henkilo;
        cin >> summa;
        index = henkilo - 'A';
        maksut[index] += summa;
        yht += summa;
    }

    int osa = yht / 4;

    int tarvittavat[4];

    int siirtoja = 0;

    for (int i = 1; i < 4; i++)
    {
        int s = osa - maksut[i];
        tarvittavat[i] = -s;
        if (s != 0)
            siirtoja++;
    }

    cout << siirtoja << "\n";

    for (int i = 1; i < 4; i++)
    {
        char henkilo = 'A' + i;
        int s = tarvittavat[i];
        if (s < 0)
        {
            cout << henkilo << " A " << -s << "\n";
        }
    }

    for (int i = 1; i < 4; i++)
    {
        char henkilo = 'A' + i;
        int s = tarvittavat[i];
        if (s > 0)
        {
            cout << "A " << henkilo << " " << s << "\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
C A 3106
A B 2266
A D 1470

Test 2

Verdict: ACCEPTED

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 2424
D A 1776
A C 3444

Test 3

Verdict: ACCEPTED

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

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

user output
3
C A 107
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
B A 514
A C 302
A D 350

Test 6

Verdict: ACCEPTED

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 767
C A 839
A D 1321

Test 7

Verdict: ACCEPTED

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 2208
D A 2920
A B 4804

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
D A 2252
A B 560
A 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
B A 1631
D A 3791
A C 5537

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