Task: | Kortit |
Sender: | otahontas |
Submission time: | 2020-09-27 17:26:41 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.01 s | 1, 2 | details |
#2 | WRONG ANSWER | 0.01 s | 2 | details |
Code
#include <iostream> #include <vector> #include <algorithm> using namespace std; void solve(int n, vector<int> v) { sort(v.begin(), v.end()); int ans = 0; int prev = 0; for (int i = 0; i < n/2; i++) { ans += v[i] - prev - 1; prev = v[i]; } cout << ans << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; for (int i = 0; i < t; i++) { int n; cin >> n; vector<int>v; v.resize(n/2); for (int j = 0; j < n/2; j++) cin >> v[j]; solve(n,v); } }