Wrong Answer
Code
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int tc; cin >> tc;
test:
while (tc--) {
ll n; cin >> n;
ll arr[n];
for (auto &u : arr) cin >> u;
sort(arr, arr+n);
// ll ans = -1e18;
// for (ll i = 1; i < n; i++) ans = max(ans, arr[i]-arr[i-1]);
ll ans = arr[n-1]-arr[n-2];
if (n >= 3 and arr[n-3] > 0) ans += arr[n-3];
cout << ans << "\n";
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1208 C. Game on Integer
- Contest
- Educational Round 1
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2025-07-14 16:27:44
- Judged At
- 2025-07-14 16:27:44
- Judged By
- Score
- 5
- Total Time
- 15ms
- Peak Memory
- 532.0 KiB