CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Kortit
Sender:kluopaja
Submission time:2020-09-26 17:52:11 +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>
#include <vector>
using namespace std;
int main() {
  int tt;
  cin>>tt;
  for(int xx = 0; xx < tt; ++xx) {
    int is_my_card[101] = {0};
    int n;
    cin>>n;
    for(int i = 0; i < n/2; ++i) {
      int a;
      cin>>a;
      is_my_card[a] = 1;
    }
    std::vector<int> my_cards;
    std::vector<int> opponent_cards;
    for(int i = 1; i <= n; ++i) {
      if(is_my_card[i]) {
        my_cards.push_back(i);
      }
      else {
        opponent_cards.push_back(i);
      }
    }
    size_t opponent_pos = 0;
    int ans = 0;
    for(size_t i = 0; i < my_cards.size(); ++i) {
      if(opponent_pos < opponent_cards.size() 
         && opponent_cards[opponent_pos] < my_cards[i]) {
        ++ans;
        ++opponent_pos;
      }
    }
    cout<<ans<<endl;
  }
}

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