Task: | Kortit |
Sender: | öppis |
Submission time: | 2020-09-25 20:30:22 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 23 |
#2 | ACCEPTED | 77 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.01 s | 1, 2 | details |
#2 | ACCEPTED | 0.01 s | 2 | details |
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; }