CSES - Leirikisa 6.3.2017 - Results
Submission details
Task:Karuselli
Sender:Pohjantahti
Submission time:2017-03-06 16:40:24 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.22 s1details
#2ACCEPTED0.20 s1details
#3ACCEPTED0.14 s1details
#4ACCEPTED0.21 s1details
#5ACCEPTED0.19 s1details
#60.22 s2details
#70.03 s2details
#80.03 s2details
#90.04 s2details
#100.05 s2details
#110.29 s3details
#120.19 s3details
#130.20 s3details
#140.17 s3details
#150.19 s3details

Code

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define F first
#define S second

int n, k;

int main() {
    cin >> n >> k;
    
    vector<pair<int, int>> v[2];
    
    for (int i = 0; i < min(n, 2); ++i) {
        for (int j = 0; j < k; ++j) {
            int cur;
            cin >> cur;
            v[i].push_back(make_pair(cur, j));
        }
        sort(v[i].begin(), v[i].end());
    } 
    
    auto p1p = *(v[0].end()-1);
    auto p1s = *(v[0].end()-2);
    
    auto p2p = *(v[1].end()-1);
    auto p2s = *(v[1].end()-2);
    
    if (p1p.S != p2p.S) {
        cout << p1p.F+p2p.F << "\n";
    }
    else {
        cout << max(p1p.F+p2s.F, p1s.F+p2p.F) << "\n";
    }
    return 0;
}

Test details

Test 1

Group: 1

Verdict:

input
1 100000
557222713 738086719 759310230 ...

correct output
999997412

user output
(empty)

Test 2

Group: 1

Verdict: ACCEPTED

input
2 100000
173028329 323213810 439376948 ...

correct output
1999979389

user output
1999979389

Test 3

Group: 1

Verdict: ACCEPTED

input
2 100000
499570894 150469086 335977485 ...

correct output
1999973920

user output
1999973920

Test 4

Group: 1

Verdict: ACCEPTED

input
2 100000
863032160 931625464 885185608 ...

correct output
1999939689

user output
1999939689

Test 5

Group: 1

Verdict: ACCEPTED

input
2 100000
831463088 525853809 390350738 ...

correct output
1999969705

user output
1999969705

Test 6

Group: 2

Verdict:

input
1 200
344318490 251860941 939326382 ...

correct output
998010019

user output
(empty)

Test 7

Group: 2

Verdict:

input
14 200
43513423 154416018 137660602 1...

correct output
13918226615

user output
1980904979

Test 8

Group: 2

Verdict:

input
14 200
881307544 967733810 371467276 ...

correct output
13961979091

user output
1995295321

Test 9

Group: 2

Verdict:

input
14 200
522563563 350867137 498280483 ...

correct output
13912986556

user output
1973735879

Test 10

Group: 2

Verdict:

input
14 200
852825364 914968833 967854069 ...

correct output
13929235436

user output
1990439361

Test 11

Group: 3

Verdict:

input
1 100000
157285470 474162109 440472842 ...

correct output
999998218

user output
(empty)

Test 12

Group: 3

Verdict:

input
14 100000
971542960 589024445 443526352 ...

correct output
13999781843

user output
1999978121

Test 13

Group: 3

Verdict:

input
14 100000
255470528 36303969 757946964 7...

correct output
13999894454

user output
1999967710

Test 14

Group: 3

Verdict:

input
14 100000
18178744 935999032 93142616 43...

correct output
13999804193

user output
1999994677

Test 15

Group: 3

Verdict:

input
14 100000
316827351 638928258 809826490 ...

correct output
13999909014

user output
1999978478