CSES - Datatähti 2018 loppu - Results
Submission details
Task:Pinopeli
Sender:ollpu
Submission time:2018-01-21 01:36:47 +0200
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED17
#2ACCEPTED22
#3ACCEPTED61
Test results
testverdicttimegroup
#1ACCEPTED0.06 s1details
#2ACCEPTED0.05 s1details
#3ACCEPTED0.05 s1details
#4ACCEPTED0.05 s1details
#5ACCEPTED0.06 s1details
#6ACCEPTED0.05 s1details
#7ACCEPTED0.03 s1details
#8ACCEPTED0.06 s1details
#9ACCEPTED0.04 s1details
#10ACCEPTED0.04 s1details
#11ACCEPTED0.05 s1details
#12ACCEPTED0.05 s1details
#13ACCEPTED0.06 s1details
#14ACCEPTED0.07 s1details
#15ACCEPTED0.05 s1details
#16ACCEPTED0.05 s1details
#17ACCEPTED0.05 s1details
#18ACCEPTED0.06 s1details
#19ACCEPTED0.06 s1details
#20ACCEPTED0.06 s1details
#21ACCEPTED0.05 s1details
#22ACCEPTED0.04 s1details
#23ACCEPTED0.04 s1details
#24ACCEPTED0.06 s1details
#25ACCEPTED0.04 s1details
#26ACCEPTED0.04 s1details
#27ACCEPTED0.05 s1details
#28ACCEPTED0.04 s1details
#29ACCEPTED0.05 s1details
#30ACCEPTED0.07 s1details
#31ACCEPTED0.06 s1details
#32ACCEPTED0.04 s1details
#33ACCEPTED0.06 s1details
#34ACCEPTED0.06 s1details
#35ACCEPTED0.04 s1details
#36ACCEPTED0.04 s1details
#37ACCEPTED0.04 s2details
#38ACCEPTED0.05 s2details
#39ACCEPTED0.08 s2details
#40ACCEPTED0.06 s2details
#41ACCEPTED0.04 s2details
#42ACCEPTED0.04 s2details
#43ACCEPTED0.05 s2details
#44ACCEPTED0.06 s2details
#45ACCEPTED0.05 s2details
#46ACCEPTED0.05 s2details
#47ACCEPTED0.05 s3details
#48ACCEPTED0.07 s3details
#49ACCEPTED0.07 s3details
#50ACCEPTED0.05 s3details
#51ACCEPTED0.06 s3details
#52ACCEPTED0.06 s3details
#53ACCEPTED0.05 s3details
#54ACCEPTED0.04 s3details
#55ACCEPTED0.06 s3details
#56ACCEPTED0.05 s3details
#57ACCEPTED0.04 s3details
#58ACCEPTED0.06 s3details
#59ACCEPTED0.06 s3details
#60ACCEPTED0.04 s3details
#61ACCEPTED0.03 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:46:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (i = 0; i+1 < o.size(); i+=2) {
                   ^
input/code.cpp:50:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (i < o.size()) {
         ^

Code

#include <iostream>
#include <sstream>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
#define F first
#define S second
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int N, A;
  cin >> N >> A;
  map<int, int> bg;
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    bg[x]++;
    sum += x;
  }
  if (A == 1) {
    if (sum&1) {
      cout << "YES\n";
      cout << "TAKE " << bg.begin()->F << " 1\n";
      cout << "KEEP 1\n";
      cout << "END\n";
    } else cout << "NO\n";
    return 0;
  }
  vector<int> o;
  for (auto p : bg) {
    if (p.S&1) o.push_back(p.F);
  }
  if (o.size() == 0) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  cout << "TAKE " << o.back() << " " << o.back() << "\n";
  int l = o.back();
  o.pop_back();
  reverse(o.begin(), o.end());
  int i;
  stringstream x;
  for (i = 0; i+1 < o.size(); i+=2) {
    x << "ADD " << o[i+1] << " " << (o[i]-o[i+1]) << "\n";
    l -= o[i]-o[i+1];
  }
  if (i < o.size()) {
    x << "ADD 0 " << o.back() << "\n";
    l -= o.back();
  }
  if (l > 2) {
    x << "ADD 0 " << (l-1)/2 << "\n";
    x << "ADD 0 " << (l-1)/2 << "\n";
    l -= 2*((l-1)/2);
  }
  cout << "KEEP " << l << "\n";
  cout << x.str();
  cout << "END\n";
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
1 1
1

correct output
YES
TAKE 1 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 2

Group: 1

Verdict: ACCEPTED

input
2 1
1 1

correct output
NO

user output
NO

Test 3

Group: 1

Verdict: ACCEPTED

input
1 1
2

correct output
NO

user output
NO

Test 4

Group: 1

Verdict: ACCEPTED

input
3 1
1 1 1

correct output
YES
TAKE 1 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 5

Group: 1

Verdict: ACCEPTED

input
2 1
2 1

correct output
YES
TAKE 2 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 6

Group: 1

Verdict: ACCEPTED

input
1 1
3

correct output
YES
TAKE 3 1
KEEP 1
END

user output
YES
TAKE 3 1
KEEP 1
END

Test 7

Group: 1

Verdict: ACCEPTED

input
4 1
1 1 1 1

correct output
NO

user output
NO

Test 8

Group: 1

Verdict: ACCEPTED

input
3 1
2 1 1

correct output
NO

user output
NO

Test 9

Group: 1

Verdict: ACCEPTED

input
2 1
2 2

correct output
NO

user output
NO

Test 10

Group: 1

Verdict: ACCEPTED

input
2 1
3 1

correct output
NO

user output
NO

Test 11

Group: 1

Verdict: ACCEPTED

input
1 1
4

correct output
NO

user output
NO

Test 12

Group: 1

Verdict: ACCEPTED

input
5 1
1 1 1 1 1

correct output
YES
TAKE 1 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 13

Group: 1

Verdict: ACCEPTED

input
4 1
2 1 1 1

correct output
YES
TAKE 2 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 14

Group: 1

Verdict: ACCEPTED

input
3 1
2 2 1

correct output
YES
TAKE 2 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 15

Group: 1

Verdict: ACCEPTED

input
2 1
2 3

correct output
YES
TAKE 3 1
KEEP 1
END

user output
YES
TAKE 2 1
KEEP 1
END

Test 16

Group: 1

Verdict: ACCEPTED

input
3 1
3 1 1

correct output
YES
TAKE 3 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 17

Group: 1

Verdict: ACCEPTED

input
2 1
4 1

correct output
YES
TAKE 4 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 18

Group: 1

Verdict: ACCEPTED

input
1 1
5

correct output
YES
TAKE 5 1
KEEP 1
END

user output
YES
TAKE 5 1
KEEP 1
END

Test 19

Group: 1

Verdict: ACCEPTED

input
1 2
1

correct output
YES
TAKE 1 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 20

Group: 1

Verdict: ACCEPTED

input
2 2
1 1

correct output
NO

user output
NO

Test 21

Group: 1

Verdict: ACCEPTED

input
1 2
2

correct output
YES
TAKE 2 2
KEEP 2
END

user output
YES
TAKE 2 2
KEEP 2
END

Test 22

Group: 1

Verdict: ACCEPTED

input
3 2
1 1 1

correct output
YES
TAKE 1 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 23

Group: 1

Verdict: ACCEPTED

input
2 2
2 1

correct output
YES
TAKE 2 2
KEEP 1
ADD 0 1
END

user output
YES
TAKE 2 2
KEEP 1
ADD 0 1
END

Test 24

Group: 1

Verdict: ACCEPTED

input
1 2
3

correct output
YES
TAKE 3 3
KEEP 1
ADD 0 1
ADD 0 1
...

user output
YES
TAKE 3 3
KEEP 1
ADD 0 1
ADD 0 1
...

Test 25

Group: 1

Verdict: ACCEPTED

input
4 2
1 1 1 1

correct output
NO

user output
NO

Test 26

Group: 1

Verdict: ACCEPTED

input
3 2
2 1 1

correct output
YES
TAKE 2 2
KEEP 2
END

user output
YES
TAKE 2 2
KEEP 2
END

Test 27

Group: 1

Verdict: ACCEPTED

input
2 2
2 2

correct output
NO

user output
NO

Test 28

Group: 1

Verdict: ACCEPTED

input
2 2
3 1

correct output
YES
TAKE 3 3
KEEP 2
ADD 0 1
END

user output
YES
TAKE 3 3
KEEP 2
ADD 0 1
END

Test 29

Group: 1

Verdict: ACCEPTED

input
1 2
4

correct output
YES
TAKE 4 4
KEEP 2
ADD 0 1
ADD 0 1
...

user output
YES
TAKE 4 4
KEEP 2
ADD 0 1
ADD 0 1
...

Test 30

Group: 1

Verdict: ACCEPTED

input
5 2
1 1 1 1 1

correct output
YES
TAKE 1 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 31

Group: 1

Verdict: ACCEPTED

input
4 2
2 1 1 1

correct output
YES
TAKE 2 2
KEEP 1
ADD 0 1
END

user output
YES
TAKE 2 2
KEEP 1
ADD 0 1
END

Test 32

Group: 1

Verdict: ACCEPTED

input
3 2
2 2 1

correct output
YES
TAKE 2 2
KEEP 1
ADD 1 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 33

Group: 1

Verdict: ACCEPTED

input
2 2
2 3

correct output
YES
TAKE 3 3
KEEP 1
ADD 0 2
END

user output
YES
TAKE 3 3
KEEP 1
ADD 0 2
END

Test 34

Group: 1

Verdict: ACCEPTED

input
3 2
3 1 1

correct output
YES
TAKE 3 3
KEEP 1
ADD 0 1
ADD 0 1
...

user output
YES
TAKE 3 3
KEEP 1
ADD 0 1
ADD 0 1
...

Test 35

Group: 1

Verdict: ACCEPTED

input
2 2
4 1

correct output
YES
TAKE 4 4
KEEP 1
ADD 0 1
ADD 0 1
...

user output
YES
TAKE 4 4
KEEP 1
ADD 0 1
ADD 0 1
...

Test 36

Group: 1

Verdict: ACCEPTED

input
1 2
5

correct output
YES
TAKE 5 5
KEEP 1
ADD 0 2
ADD 0 2
...

user output
YES
TAKE 5 5
KEEP 1
ADD 0 2
ADD 0 2
...

Test 37

Group: 2

Verdict: ACCEPTED

input
6 1
5 2 3 1 6 3

correct output
NO

user output
NO

Test 38

Group: 2

Verdict: ACCEPTED

input
5 1
1 2 3 4 5

correct output
YES
TAKE 5 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 39

Group: 2

Verdict: ACCEPTED

input
7 1
2 2 2 2 2 2 5

correct output
YES
TAKE 5 1
KEEP 1
END

user output
YES
TAKE 2 1
KEEP 1
END

Test 40

Group: 2

Verdict: ACCEPTED

input
20 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
NO

user output
NO

Test 41

Group: 2

Verdict: ACCEPTED

input
4 1
7 7 2 2

correct output
NO

user output
NO

Test 42

Group: 2

Verdict: ACCEPTED

input
6 2
5 2 3 1 6 3

correct output
YES
TAKE 6 6
KEEP 2
ADD 3 2
ADD 2 1
...

user output
YES
TAKE 6 6
KEEP 2
ADD 2 3
ADD 0 1
...

Test 43

Group: 2

Verdict: ACCEPTED

input
5 3
1 2 3 4 5

correct output
YES
TAKE 5 5
KEEP 1
ADD 3 1
ADD 1 1
...

user output
YES
TAKE 5 5
KEEP 1
ADD 3 1
ADD 1 1
...

Test 44

Group: 2

Verdict: ACCEPTED

input
7 5
2 2 2 2 2 2 5

correct output
YES
TAKE 5 5
KEEP 1
ADD 0 2
ADD 0 2
...

user output
YES
TAKE 5 5
KEEP 1
ADD 0 2
ADD 0 2
...

Test 45

Group: 2

Verdict: ACCEPTED

input
20 5
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
NO

user output
NO

Test 46

Group: 2

Verdict: ACCEPTED

input
4 4
7 7 2 2

correct output
NO

user output
NO

Test 47

Group: 3

Verdict: ACCEPTED

input
500 1
489 402 131 79 196 338 319 1 2...

correct output
YES
TAKE 500 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 48

Group: 3

Verdict: ACCEPTED

input
500 1
222 9 263 104 241 286 306 4 35...

correct output
YES
TAKE 498 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 49

Group: 3

Verdict: ACCEPTED

input
500 1
102 275 66 352 310 448 152 19 ...

correct output
NO

user output
NO

Test 50

Group: 3

Verdict: ACCEPTED

input
500 1
62 458 377 166 75 238 345 76 1...

correct output
YES
TAKE 500 1
KEEP 1
END

user output
YES
TAKE 1 1
KEEP 1
END

Test 51

Group: 3

Verdict: ACCEPTED

input
500 1
206 409 99 306 53 351 188 463 ...

correct output
YES
TAKE 498 1
KEEP 1
END

user output
YES
TAKE 2 1
KEEP 1
END

Test 52

Group: 3

Verdict: ACCEPTED

input
500 468
280 36 405 277 160 440 276 63 ...

correct output
YES
TAKE 498 498
KEEP 2
ADD 494 2
ADD 492 2
...

user output
YES
TAKE 498 498
KEEP 2
ADD 492 4
ADD 489 1
...

Test 53

Group: 3

Verdict: ACCEPTED

input
500 298
32 22 455 427 85 483 397 391 2...

correct output
YES
TAKE 500 500
KEEP 2
ADD 496 4
ADD 493 1
...

user output
YES
TAKE 496 496
KEEP 2
ADD 493 1
ADD 489 2
...

Test 54

Group: 3

Verdict: ACCEPTED

input
500 294
162 263 109 294 201 81 66 278 ...

correct output
YES
TAKE 500 500
KEEP 2
ADD 499 1
ADD 495 2
...

user output
YES
TAKE 499 499
KEEP 2
ADD 495 2
ADD 488 3
...

Test 55

Group: 3

Verdict: ACCEPTED

input
500 102
15 57 414 4 390 362 236 250 98...

correct output
YES
TAKE 499 499
KEEP 2
ADD 492 3
ADD 491 1
...

user output
YES
TAKE 499 499
KEEP 2
ADD 489 6
ADD 485 2
...

Test 56

Group: 3

Verdict: ACCEPTED

input
500 336
170 375 337 6 248 262 286 304 ...

correct output
YES
TAKE 498 498
KEEP 2
ADD 494 2
ADD 490 4
...

user output
YES
TAKE 498 498
KEEP 2
ADD 490 6
ADD 486 2
...

Test 57

Group: 3

Verdict: ACCEPTED

input
500 209
5 390 188 108 124 385 390 380 ...

correct output
NO

user output
NO

Test 58

Group: 3

Verdict: ACCEPTED

input
500 217
102 116 309 329 245 174 94 358...

correct output
NO

user output
NO

Test 59

Group: 3

Verdict: ACCEPTED

input
500 218
366 422 444 234 247 152 122 44...

correct output
NO

user output
NO

Test 60

Group: 3

Verdict: ACCEPTED

input
500 207
275 384 115 426 47 451 426 272...

correct output
NO

user output
NO

Test 61

Group: 3

Verdict: ACCEPTED

input
500 400
33 243 65 284 436 139 334 284 ...

correct output
NO

user output
NO