My issue
I got the right idea of how to solve this problem. Why did i get WA during the contest?
My code
#include <bits/stdc++.h>
using namespace std;
void solve() {
int t;
cin >> t;
while(t--) {
int n, m;
cin >> n >> m;
int arr[m];
long long int sumM = 0;
for(int i = 0; i < m; i++) {
cin >> arr[i];
sumM += arr[i];
}
long long int sumN = n*(n+1) / 2;
cout << sumN - sumM << endl;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
solve();
return 0;
}
Problem Link: REMOVEMUL Problem - CodeChef