CSES - Aalto Competitive Programming 2024 - wk10 - Wed - Results
Submission details
Task:Gas tank
Sender:aalto2024k_001
Submission time:2024-11-13 17:42:44 +0200
Language:C++ (C++17)
Status:READY
Result:
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
#12ACCEPTED0.00 sdetails
#13ACCEPTED0.00 sdetails
#14ACCEPTED0.00 sdetails
#15ACCEPTED0.00 sdetails
#16ACCEPTED0.00 sdetails
#17ACCEPTED0.00 sdetails
#18ACCEPTED0.00 sdetails
#19ACCEPTED0.00 sdetails
#20ACCEPTED0.00 sdetails
#21ACCEPTED0.00 sdetails
#22ACCEPTED0.00 sdetails
#23ACCEPTED0.00 sdetails
#24ACCEPTED0.00 sdetails
#25ACCEPTED0.00 sdetails
#26ACCEPTED0.00 sdetails
#27ACCEPTED0.00 sdetails
#28ACCEPTED0.00 sdetails
#29ACCEPTED0.00 sdetails
#30ACCEPTED0.00 sdetails
#31ACCEPTED0.00 sdetails
#32ACCEPTED0.00 sdetails
#33ACCEPTED0.00 sdetails
#34ACCEPTED0.00 sdetails
#35ACCEPTED0.00 sdetails
#36ACCEPTED0.00 sdetails
#37ACCEPTED0.00 sdetails
#38ACCEPTED0.00 sdetails
#39ACCEPTED0.00 sdetails
#40ACCEPTED0.00 sdetails
#41ACCEPTED0.00 sdetails
#42ACCEPTED0.00 sdetails
#43ACCEPTED0.00 sdetails
#44ACCEPTED0.00 sdetails
#45ACCEPTED0.00 sdetails
#46ACCEPTED0.00 sdetails
#47ACCEPTED0.00 sdetails
#48ACCEPTED0.00 sdetails
#49ACCEPTED0.00 sdetails
#50ACCEPTED0.00 sdetails
#51ACCEPTED0.00 sdetails
#52ACCEPTED0.00 sdetails
#53ACCEPTED0.00 sdetails
#54ACCEPTED0.00 sdetails
#55ACCEPTED0.00 sdetails
#56ACCEPTED0.00 sdetails
#57ACCEPTED0.00 sdetails
#580.00 sdetails
#59ACCEPTED0.00 sdetails
#600.00 sdetails
#610.01 sdetails
#620.01 sdetails
#630.01 sdetails
#640.01 sdetails
#650.01 sdetails
#660.01 sdetails
#670.01 sdetails
#680.01 sdetails
#690.00 sdetails
#700.01 sdetails
#710.01 sdetails
#720.01 sdetails
#730.01 sdetails
#740.01 sdetails
#750.00 sdetails
#760.01 sdetails
#770.01 sdetails
#780.00 sdetails
#790.01 sdetails
#800.01 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:67:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'ull' {aka 'long long unsigned int'} [-Wsign-compare]
   67 |     for(ll b=1; b<=maxv; b++){
      |                 ~^~~~~~

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

ll val(ll A, ll B){
    return A*A*B + B*B*A;
}

ll binsearchA(ll B, ll N){
    ll a1 = 0;
    ll a2 = N; 

    while(a2 - a1 > 1){
        ll mid = (a2 + a1) / 2;
        if(val(mid, B) <= N){
            a1 = mid;
        }
        else{
            a2 = mid;
        }
    }
    return a1;
}

// ll binsearchA(ll B, ll N){
//     ll b = 1<<30;
//     ll a = 0;
//     ll s = 0;

//     while(b){
//         ll a2 = a | b;
//         ll v = val(a2, B);
//         ll s2 = N - v;
//         // cout << "this: " << a2 << " " << s2 << "\n";
//         if(s2 >= 0){
//             s = s2;
//             a = a2;
//         }
//         b >>= 1;
//     }
//     return a;
// }

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll N;
    cin >> N;

    if(N == 0){
        cout << "0 0\n";
        return 0;
    }
    if(N == 1){
        cout << "1 0\n";
        return 0;
    }

    ull maxv = pow(N+100, 1.0/3)+10;
    ll bA = 0, bB = 0;
    ll bS = LLONG_MAX;

    // cout << "bets b: " << maxv << "\n";

    for(ll b=1; b<=maxv; b++){
        ll a = binsearchA(b, N);
        // cout << ": " << a << "\n";
        // break;
        // cout << "this: " << b << " " << a << "\n";
        ll v = val(a,b);
        ll s = N - v;
        if(s >= 0 && s < bS){
            bS = s;
            bA = a;
            bB = b;
        }
    }
    cout << bA << " " << bB << "\n";
}

Test details

Test 1

Verdict: ACCEPTED

input
8

correct output
2 1

user output
2 1

Test 2

Verdict: ACCEPTED

input
7

correct output
2 1

user output
2 1

Test 3

Verdict: ACCEPTED

input
46

correct output
6 1

user output
6 1

Test 4

Verdict: ACCEPTED

input
28

correct output
4 1

user output
4 1

Test 5

Verdict: ACCEPTED

input
40

correct output
5 1

user output
5 1

Test 6

Verdict: ACCEPTED

input
34

correct output
5 1

user output
5 1

Test 7

Verdict: ACCEPTED

input
39

correct output
5 1

user output
5 1

Test 8

Verdict: ACCEPTED

input
38

correct output
5 1

user output
5 1

Test 9

Verdict: ACCEPTED

input
25

correct output
4 1

user output
4 1

Test 10

Verdict: ACCEPTED

input
26

correct output
4 1

user output
4 1

Test 11

Verdict: ACCEPTED

input
549

correct output
7 6

user output
7 6

Test 12

Verdict: ACCEPTED

input
418

correct output
13 2

user output
13 2

Test 13

Verdict: ACCEPTED

input
436

correct output
6 6

user output
6 6

Test 14

Verdict: ACCEPTED

input
551

correct output
7 6

user output
7 6

Test 15

Verdict: ACCEPTED

input
968

correct output
21 2

user output
21 2

Test 16

Verdict: ACCEPTED

input
222

correct output
14 1

user output
14 1

Test 17

Verdict: ACCEPTED

input
893

correct output
13 4

user output
13 4

Test 18

Verdict: ACCEPTED

input
77

correct output
8 1

user output
8 1

Test 19

Verdict: ACCEPTED

input
874

correct output
29 1

user output
29 1

Test 20

Verdict: ACCEPTED

input
11

correct output
2 1

user output
2 1

Test 21

Verdict: ACCEPTED

input
772

correct output
12 4

user output
12 4

Test 22

Verdict: ACCEPTED

input
181

correct output
5 4

user output
5 4

Test 23

Verdict: ACCEPTED

input
155

correct output
11 1

user output
11 1

Test 24

Verdict: ACCEPTED

input
778

correct output
12 4

user output
12 4

Test 25

Verdict: ACCEPTED

input
514

correct output
15 2

user output
15 2

Test 26

Verdict: ACCEPTED

input
849

correct output
8 7

user output
8 7

Test 27

Verdict: ACCEPTED

input
224

correct output
14 1

user output
14 1

Test 28

Verdict: ACCEPTED

input
295

correct output
11 2

user output
11 2

Test 29

Verdict: ACCEPTED

input
651

correct output
25 1

user output
25 1

Test 30

Verdict: ACCEPTED

input
98

correct output
6 2

user output
6 2

Test 31

Verdict: ACCEPTED

input
588264

correct output
172 18

user output
172 18

Test 32

Verdict: ACCEPTED

input
48736

correct output
80 7

user output
80 7

Test 33

Verdict: ACCEPTED

input
208508

correct output
99 18

user output
99 18

Test 34

Verdict: ACCEPTED

input
517415

correct output
172 16

user output
172 16

Test 35

Verdict: ACCEPTED

input
960234

correct output
290 11

user output
290 11

Test 36

Verdict: ACCEPTED

input
870321

correct output
111 49

user output
111 49

Test 37

Verdict: ACCEPTED

input
308005

correct output
70 40

user output
70 40

Test 38

Verdict: ACCEPTED

input
425818

correct output
652 1

user output
652 1

Test 39

Verdict: ACCEPTED

input
729178

correct output
83 61

user output
83 61

Test 40

Verdict: ACCEPTED

input
863955

correct output
535 3

user output
535 3

Test 41

Verdict: ACCEPTED

input
116086

correct output
340 1

user output
340 1

Test 42

Verdict: ACCEPTED

input
612309

correct output
782 1

user output
782 1

Test 43

Verdict: ACCEPTED

input
375142

correct output
228 7

user output
228 7

Test 44

Verdict: ACCEPTED

input
852178

correct output
161 28

user output
161 28

Test 45

Verdict: ACCEPTED

input
151667

correct output
156 6

user output
156 6

Test 46

Verdict: ACCEPTED

input
196137

correct output
103 16

user output
103 16

Test 47

Verdict: ACCEPTED

input
375254

correct output
612 1

user output
612 1

Test 48

Verdict: ACCEPTED

input
451513

correct output
298 5

user output
298 5

Test 49

Verdict: ACCEPTED

input
942864

correct output
122 46

user output
122 46

Test 50

Verdict: ACCEPTED

input
848035

correct output
215 17

user output
215 17

Test 51

Verdict: ACCEPTED

input
727949226

correct output
1876 188

user output
1876 188

Test 52

Verdict: ACCEPTED

input
119540561

correct output
395 387

user output
395 387

Test 53

Verdict: ACCEPTED

input
168568700

correct output
447 430

user output
447 430

Test 54

Verdict: ACCEPTED

input
747828096

correct output
2098 158

user output
2098 158

Test 55

Verdict: ACCEPTED

input
113886324

correct output
949 113

user output
949 113

Test 56

Verdict: ACCEPTED

input
544092912

correct output
2620 77

user output
2620 77

Test 57

Verdict: ACCEPTED

input
112927706

correct output
532 266

user output
532 266

Test 58

Verdict:

input
562461747

correct output
1803 159

user output
4315 30

Test 59

Verdict: ACCEPTED

input
930544437

correct output
7390 17

user output
7390 17

Test 60

Verdict:

input
612603672

correct output
1128 364

user output
1653 200

Test 61

Verdict:

input
575864416073

correct output
7427 5843

user output
120529234575 95

Test 62

Verdict:

input
942935707814

correct output
63092 236

user output
5678296086 357

Test 63

Verdict:

input
171264013251

correct output
14433 780

user output
5452 3506

Test 64

Verdict:

input
76712165827

correct output
8381 978

user output
9239 825

Test 65

Verdict:

input
161612205399

correct output
7527 2206

user output
4788 3889

Test 66

Verdict:

input
641183113758

correct output
50116 254

user output
7891929709 93

Test 67

Verdict:

input
87822361843

correct output
24538 145

user output
93708 10

Test 68

Verdict:

input
550401843854

correct output
14093 2372

user output
5909950427 3331

Test 69

Verdict:

input
56603972680

correct output
10404 499

user output
11682 401

Test 70

Verdict:

input
991404337870

correct output
109250 83

user output
11064 5432

Test 71

Verdict:

input
534149659344

correct output
53496 186

user output
4959401065 3

Test 72

Verdict:

input
336010906011

correct output
183301 10

user output
39241 217

Test 73

Verdict:

input
871714540470

correct output
214186 19

user output
4669121703 22

Test 74

Verdict:

input
254659717917

correct output
17240 818

user output
28185 317

Test 75

Verdict:

input
40507166127

correct output
3335 2196

user output
12817 242

Test 76

Verdict:

input
445628406612

correct output
23039 811

user output
33608 390

Test 77

Verdict:

input
822717753419

correct output
39363 524

user output
5851 9288

Test 78

Verdict:

input
40410210216

correct output
10096 382

user output
14647 186

Test 79

Verdict:

input
366117794932

correct output
49165 151

user output
43801 190

Test 80

Verdict:

input
657992849714

correct output
11698 3662

user output
11795 3619