CSES - Aalto Competitive Programming 2024 - wk2 - Wed - Results
Submission details
Task:Old legos
Sender:aalto2024b_001
Submission time:2024-09-11 17:07:30 +0300
Language:C++ (C++11)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#50.00 sdetails
#6ACCEPTED0.00 sdetails
#70.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.00 sdetails
#110.00 sdetails
#120.00 sdetails
#130.00 sdetails
#14ACCEPTED0.00 sdetails
#150.00 sdetails
#160.00 sdetails
#170.00 sdetails
#180.00 sdetails
#19ACCEPTED0.00 sdetails
#200.00 sdetails
#210.00 sdetails
#220.00 sdetails
#230.00 sdetails
#240.00 sdetails
#250.00 sdetails
#260.00 sdetails
#270.00 sdetails
#280.00 sdetails
#290.00 sdetails
#300.00 sdetails
#310.00 sdetails
#320.00 sdetails
#330.00 sdetails
#340.00 sdetails
#350.00 sdetails
#360.00 sdetails
#370.00 sdetails
#380.00 sdetails
#390.00 sdetails
#400.00 sdetails
#410.00 sdetails
#420.00 sdetails
#430.00 sdetails
#440.00 sdetails
#450.00 sdetails
#460.00 sdetails
#470.00 sdetails
#480.00 sdetails
#490.00 sdetails
#500.00 sdetails
#510.00 sdetails
#520.01 sdetails
#530.00 sdetails
#540.00 sdetails
#550.01 sdetails
#560.00 sdetails
#570.00 sdetails
#580.00 sdetails
#590.01 sdetails
#600.08 sdetails
#610.10 sdetails
#620.10 sdetails
#630.08 sdetails
#640.09 sdetails
#650.10 sdetails
#660.08 sdetails
#670.10 sdetails
#680.09 sdetails
#690.10 sdetails

Code

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <tuple>
#include <vector>

using namespace std;

int main (int argc, char *argv[]) {
    int n;
    cin >> n;
    vector<tuple<int, int, int>> legos(n);
    for (int i = 0; i < n; i++) {
        int uolevi, maija;
        cin >> uolevi >> maija;
        legos[i] = make_tuple(uolevi - maija, uolevi, maija);
    }
    sort(legos.begin(), legos.end());
    /*for (int i = 0; i < n; i++) {*/
    /*    cout << get<0>(legos[i]) << " ";*/
    /*    cout << get<1>(legos[i]) << " ";*/
    /*    cout << get<2>(legos[i]) << " \n";*/
    /*}*/

    int uolevi_sum = 0;
    int maija_sum = 0;
    int half_way = n / 2;
    for (int i = 0; i < half_way; i++) {
        maija_sum += get<2>(legos[i]);
    }
    for (int i = half_way; i < n; i++) {
        uolevi_sum += get<1>(legos[i]);
    }

    cout << uolevi_sum - maija_sum;

    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
1
9 2

correct output
9

user output
9

Test 2

Verdict: ACCEPTED

input
1
10 4

correct output
10

user output
10

Test 3

Verdict: ACCEPTED

input
2
8 1
3 5

correct output
3

user output
3

Test 4

Verdict: ACCEPTED

input
2
2 9
3 10

correct output
-6

user output
-6

Test 5

Verdict:

input
3
7 2
6 2
2 3

correct output
7

user output
10

Test 6

Verdict: ACCEPTED

input
3
3 2
7 9
3 8

correct output
2

user output
2

Test 7

Verdict:

input
4
5 10
9 9
1 10
8 8

correct output
-4

user output
-3

Test 8

Verdict:

input
4
3 2
7 9
3 8
4 6

correct output
1

user output
-4

Test 9

Verdict:

input
4
5 3
8 1
9 1
3 3

correct output
10

user output
11

Test 10

Verdict:

input
5
3 9
3 6
5 2
2 5
...

correct output
5

user output
3

Test 11

Verdict:

input
5
10 8
10 1
2 4
10 2
...

correct output
17

user output
25

Test 12

Verdict:

input
5
2 1
10 6
10 5
5 5
...

correct output
8

user output
13

Test 13

Verdict:

input
5
8 9
2 6
3 5
1 1
...

correct output
3

user output
1

Test 14

Verdict: ACCEPTED

input
5
6 1
9 3
3 6
2 10
...

correct output
1

user output
1

Test 15

Verdict:

input
5
1 9
9 3
4 10
10 5
...

correct output
1

user output
7

Test 16

Verdict:

input
5
4 1
1 1
1 10
1 6
...

correct output
-4

user output
-9

Test 17

Verdict:

input
5
3 8
4 5
10 8
5 10
...

correct output
1

user output
0

Test 18

Verdict:

input
5
10 3
4 2
3 2
7 5
...

correct output
11

user output
18

Test 19

Verdict: ACCEPTED

input
5
4 6
5 5
1 2
4 2
...

correct output
1

user output
1

Test 20

Verdict:

input
10
3 9
3 6
5 2
2 5
...

correct output
-5

user output
-14

Test 21

Verdict:

input
10
10 8
10 1
2 4
10 2
...

correct output
20

user output
27

Test 22

Verdict:

input
11
198730372 27838076
590195590 467423861
520495379 451366491
344173378 354694313
...

correct output
1075637330

user output
1657745825

Test 23

Verdict:

input
10
8 9
2 6
3 5
1 1
...

correct output
-3

user output
-9

Test 24

Verdict:

input
10
6 1
9 3
3 6
2 10
...

correct output
-2

user output
-7

Test 25

Verdict:

input
11
59249204 934941692
892631472 221963002
390559518 986350949
524427523 96444602
...

correct output
1389122128

user output
1205814761

Test 26

Verdict:

input
10
4 1
1 1
1 10
1 6
...

correct output
-6

user output
-19

Test 27

Verdict:

input
11
244103474 837431431
342493822 470738321
776814822 489180570
330726191 578205540
...

correct output
-124259424

user output
-268922789

Test 28

Verdict:

input
10
10 3
4 2
3 2
7 5
...

correct output
4

user output
3

Test 29

Verdict:

input
11
391337048 538883744
535937150 532332526
8099343 143698367
339543270 152590624
...

correct output
246913369

user output
795434897

Test 30

Verdict:

input
101
3 906523441
3 585063857
454895875 2
2 469855690
...

correct output
-1950121670

user output
-189120421

Test 31

Verdict:

input
100
773442532 122816
137572579 324627123
157577940 253498609
99147813 425825313
...

correct output
2484533534

user output
-1159884275

Test 32

Verdict:

input
100
198730372 27838076
590195590 467423861
520495379 451366491
344173378 354694313
...

correct output
1162250085

user output
1806564182

Test 33

Verdict:

input
100
760367935 901888417
130275571 548496961
3 469291685
20130523 1
...

correct output
-513884705

user output
-1031673305

Test 34

Verdict:

input
100
587586158 1
918715995 3
3 641621091
151896000 241061404
...

correct output
4449680753

user output
1444381201

Test 35

Verdict:

input
100
59249204 934941692
892631472 221963002
390559518 986350949
524427523 96444602
...

correct output
2289597915

user output
1770117325

Test 36

Verdict:

input
101
356460601 1
68992860 1
1 638932295
568887059 653343572
...

correct output
-1011275811

user output
1470058660

Test 37

Verdict:

input
100
244103474 837431431
342493822 470738321
776814822 489180570
330726191 578205540
...

correct output
-3347612884

user output
1304504195

Test 38

Verdict:

input
100
257096283 933290530
2 876668629
453495728 12239373
2 822553808
...

correct output
-5234322969

user output
-689569742

Test 39

Verdict:

input
101
391337048 538883744
535937150 532332526
8099343 143698367
339543270 152590624
...

correct output
1057263569

user output
-187087346

Test 40

Verdict:

input
200
3 906523441
3 585063857
454895875 2
2 469855690
...

correct output
-1859110273

user output
-2012288813

Test 41

Verdict:

input
201
773442532 122816
137572579 324627123
157577940 253498609
99147813 425825313
...

correct output
-1706556434

user output
32767296

Test 42

Verdict:

input
200
198730372 27838076
590195590 467423861
520495379 451366491
344173378 354694313
...

correct output
2881192575

user output
1273450023

Test 43

Verdict:

input
200
760367935 901888417
130275571 548496961
3 469291685
20130523 1
...

correct output
367410203

user output
-452943358

Test 44

Verdict:

input
201
587586158 1
918715995 3
3 641621091
151896000 241061404
...

correct output
6064184122

user output
476887600

Test 45

Verdict:

input
200
59249204 934941692
892631472 221963002
390559518 986350949
524427523 96444602
...

correct output
-541796892

user output
168436512

Test 46

Verdict:

input
200
356460601 1
68992860 1
1 638932295
568887059 653343572
...

correct output
-3818748427

user output
-2105339584

Test 47

Verdict:

input
201
244103474 837431431
342493822 470738321
776814822 489180570
330726191 578205540
...

correct output
1128073230

user output
-1056660010

Test 48

Verdict:

input
200
257096283 933290530
2 876668629
453495728 12239373
2 822553808
...

correct output
-4097764173

user output
-182026958

Test 49

Verdict:

input
201
391337048 538883744
535937150 532332526
8099343 143698367
339543270 152590624
...

correct output
4209206317

user output
-1436600094

Test 50

Verdict:

input
1001
3 906523441
3 585063857
454895875 2
2 469855690
...

correct output
797530744

user output
-619371801

Test 51

Verdict:

input
1000
773442532 122816
137572579 324627123
157577940 253498609
99147813 425825313
...

correct output
-6859401550

user output
-1513713420

Test 52

Verdict:

input
1000
198730372 27838076
590195590 467423861
520495379 451366491
344173378 354694313
...

correct output
3341433705

user output
-2085223464

Test 53

Verdict:

input
1000
760367935 901888417
130275571 548496961
3 469291685
20130523 1
...

correct output
3932941646

user output
-1678013240

Test 54

Verdict:

input
1000
587586158 1
918715995 3
3 641621091
151896000 241061404
...

correct output
12940904658

user output
-893493051

Test 55

Verdict:

input
1000
59249204 934941692
892631472 221963002
390559518 986350949
524427523 96444602
...

correct output
-11353638361

user output
1028936200

Test 56

Verdict:

input
1001
356460601 1
68992860 1
1 638932295
568887059 653343572
...

correct output
196162653

user output
-1012273427

Test 57

Verdict:

input
1000
244103474 837431431
342493822 470738321
776814822 489180570
330726191 578205540
...

correct output
8993059628

user output
905736731

Test 58

Verdict:

input
1000
257096283 933290530
2 876668629
453495728 12239373
2 822553808
...

correct output
-11284740290

user output
1278691695

Test 59

Verdict:

input
1001
391337048 538883744
535937150 532332526
8099343 143698367
339543270 152590624
...

correct output
12730443353

user output
-1459176352

Test 60

Verdict:

input
100000
3 906523441
3 585063857
454895875 2
2 469855690
...

correct output
105607728400

user output
-1161163680

Test 61

Verdict:

input
100000
773442532 122816
137572579 324627123
157577940 253498609
99147813 425825313
...

correct output
21174476635

user output
1702038093

Test 62

Verdict:

input
100000
198730372 27838076
590195590 467423861
520495379 451366491
344173378 354694313
...

correct output
65624350916

user output
-2067235319

Test 63

Verdict:

input
100000
760367935 901888417
130275571 548496961
3 469291685
20130523 1
...

correct output
66836037029

user output
326051381

Test 64

Verdict:

input
100000
587586158 1
918715995 3
3 641621091
151896000 241061404
...

correct output
-87105533715

user output
-591858770

Test 65

Verdict:

input
100000
59249204 934941692
892631472 221963002
390559518 986350949
524427523 96444602
...

correct output
-1093858395

user output
1644908546

Test 66

Verdict:

input
99999
356460601 1
68992860 1
1 638932295
568887059 653343572
...

correct output
-28178672820

user output
-2062077666

Test 67

Verdict:

input
99999
244103474 837431431
342493822 470738321
776814822 489180570
330726191 578205540
...

correct output
72715249868

user output
1239134559

Test 68

Verdict:

input
99999
257096283 933290530
2 876668629
453495728 12239373
2 822553808
...

correct output
-46790665125

user output
1734786231

Test 69

Verdict:

input
99999
391337048 538883744
535937150 532332526
8099343 143698367
339543270 152590624
...

correct output
12190306919

user output
1526016776