QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#201155 | #7342. Waiter's Problem | kjhhjki | WA | 70ms | 4036kb | C++20 | 707b | 2023-10-05 12:47:31 | 2023-10-05 12:47:31 |
Judging History
answer
#include <bits/stdc++.h>
#define MAXN 100005
#define For(I,A,B) for(int I = (A), endi = (B); I <= endi; ++I)
#define foR(I,A,B) for(int I = (A), endi = (B); I >= endi; --I)
#define ForE(I,A) for(int I = head[A]; I; I = e[I].nxt)
using namespace std;
typedef long long _ll;
typedef unsigned int ui;
int T,n,a[MAXN];
_ll sum,ans;
void solve()
{
cin >> n; ans = sum = 0;
For(i,1,n) cin >> a[i];
sort(a+1,a+n+1,greater<int>());
For(i,1,n)
{
sum += a[i];
ans = max(ans, sum-1ll*i*(i-1)/2);
}
cout << ans;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> T;
while(T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
input:
1 6 0 9 9 1 7 5
output:
24
result:
ok 1 number(s): "24"
Test #2:
score: -100
Wrong Answer
time: 70ms
memory: 4036kb
input:
10007 2 6 2 5 2 3 2 10 6 2 5 0 2 1 7 6 2 4 4 2 1 5 8 6 10 1 8 0 10 9 0 3 10 5 5 10 4 9 9 5 5 2 6 7 9 4 1 7 2 0 0 7 9 4 4 6 1 8 2 10 6 6 8 6 4 4 7 2 1 8 9 7 4 9 8 3 0 2 0 10 4 1 4 9 4 2 2 5 3 5 1 3 10 4 1 6 5 3 8 6 3 2 3 10 0 0 2 9 2 1 10 6 8 6 9 2 4 1 4 2 8 5 3 0 2 4 10 9 2 7 9 2 7 3 9 5 2 5 3 5 5 9...
output:
716571033173070212628146719291513271615327216259292713291322242413222262326539418213073740202145262521231511641916726131167412115271633332422231217181683021211510172916622251617302830201827242214261010241421252681962715111619830272429652432368278328103025271119172426314101822236415224272616202350121...
result:
wrong output format Expected integer, but "716571033173070212628146719291...3665421664682065629969158627432" found