CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Kortit
Sender:öppis
Submission time:2020-09-25 20:30:22 +0300
Language:C++ (C++11)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED23
#2ACCEPTED77
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2ACCEPTED0.01 s2details

Code

#include <iostream>
using namespace std;

int t[1001];
int lkm;
int n, m;

int main() {
  cin >> lkm;
  int i, x, voitto, omat;
  while (lkm>0) {
    cin >> n;
    m=(int)(n/2);
    for (i=1; i<=n; i++) t[i]=0;
    for (i=0; i<m; i++) {cin >> x; t[x]=1;}
    voitto=0; omat=0;
    for (i=n; i>0; i--){
      if (t[i]) omat++;
      else
        if (omat>0) {omat--; voitto++;}
    }
    cout << voitto << endl;
    lkm--;
  }
  return 0;
}




Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

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: ACCEPTED

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