QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#242658#7342. Waiter's ProblemPetroTarnavskyi#AC ✓71ms3792kbC++20745b2023-11-07 16:09:402023-11-07 16:09:40

Judging History

你现在查看的是最新测评结果

  • [2023-11-07 16:09:40]
  • 评测
  • 测评结果:AC
  • 用时:71ms
  • 内存:3792kb
  • [2023-11-07 16:09:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;

int main()
{
	ios::sync_with_stdio(0); 
	cin.tie(0);
	cout << fixed << setprecision(15);
	int z;
	cin >> z;
	while (z--)
	{
		int n;
		cin >> n;
		VI a(n);
		for (int& ai : a)
			cin >> ai;
		sort(ALL(a), greater());
		LL s = 0;
		FOR(i, 0, n)
		{
			s += max(0, a[i] - i);
		}
		cout << s << "\n";
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3460kb

input:

1
6
0 9 9 1 7 5

output:

24

result:

ok 1 number(s): "24"

Test #2:

score: 0
Accepted
time: 71ms
memory: 3792kb

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:

7
16
5
7
10
33
17
30
7
0
21
26
28
14
6
7
19
29
15
13
27
16
15
32
7
21
6
25
9
29
27
13
29
13
22
24
24
13
22
22
6
23
26
5
3
9
41
8
21
30
7
37
40
20
2
14
5
26
25
21
23
15
1
16
4
19
16
7
26
13
11
6
7
41
21
15
27
16
33
33
24
22
23
12
17
18
16
8
30
21
21
15
10
17
29
16
6
22
25
16
1
7
30
28
30
20
18
27
24
...

result:

ok 10007 numbers