Run ID Author Problem Lang Verdict Score Time Memory Code Length Submit Time
5331 A班-许锘林 艺术作品算分 C++ Wrong Answer 20 0 MS 292 KB 648 2025-02-05 15:49:09

Tests(1/5):


#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int a[10010]; for(int i = 1;i <= n;i++) { cin>>a[i]; } sort(a,a + n + 1); int A = 0,b = 0; int sum = -1; if(n % 2 == 1) { A += a[n]; a[n] = -1; } else { A += a[n]; a[n] = -1; } for(int i = n;i >= 1;i--) { if(i - 2 < 1) { if(sum == -1) { b += a[i]; } else { A += a[i]; } break; } if(a[i] != -1) { if(sum == -1) { b += a[i] + a[i - 1]; } else { A += a[i] + a[i - 1]; } sum *= -1; i--; } } cout<<abs(A - b); return 0; }


Judgement Protocol: