CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Kortit
Sender:AtskaFin
Submission time:2020-09-25 18:43:35 +0300
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#10.01 s1, 2details
#20.01 s2details

Compiler report

input/code.cpp: In function 'void f()':
input/code.cpp:28:7: warning: unused variable 'cardsLeft' [-Wunused-variable]
   int cardsLeft = half;
       ^~~~~~~~~

Code

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

using namespace std;

int n, half;
vector<int> a;
vector<int> b;

void f() {
  cin >> n;
  half = n/2;

  a.clear();
  b.clear();
  a.resize(half);
  
  for (int i = 0; i < half; i++) cin >> a[i];
  sort(a.rbegin(), a.rend());

  for (int i = n, ii = 0; i > 0; i--) {
    if (i == a[ii]) ii++;
    else (b.push_back(i));
  }

  int points = 0;
  int cardsLeft = half;
  for (int i = half, ia = 0, ib = 0; i > 0; i--) {
    if (a[ia] > b[ib]) {
      points++;
      ib++;
      ia++;
    } else {
      ib++;
    }
  }

  cout << points << "\n";
}

int t;

int main() {
  cin >> t;
  for (int i = 0; i < t; i++) f();
}

Test details

Test 1

Group: 1, 2

Verdict:

input
1000
2
1
6
2 4 5
...

correct output
0
2
0
2
1
...

user output
0
2
0
2
1
...
Truncated

Test 2

Group: 2

Verdict:

input
1000
70
56 23 58 70 2 57 27 61 47 3 42...

correct output
30
15
1
38
29
...

user output
30
15
1
38
29
...
Truncated