#include <iostream>
#include <vector>
#include <algorithm>
long long sum(long long i, long long j, std::vector<long long>& PS) {
return PS[j] - (i == 0 ? 0 : PS[i - 1]);
}
int main()
{
long long N;
std::cin >> N;
std::vector<std::pair<long long, long long>> P(N);
for (auto& [a, b] : P) {
std::cin >> a >> b;
}
std::sort(P.begin(), P.end());
std::vector<long long> PSA(N);
PSA[0] = P[0].second;
for (long long i = 1; i < N; i++) {
PSA[i] = PSA[i - 1] + P[i].second;
}
long long result = 0;
for (long long i = 0; i < N; i++) {
for (long long j = i; j < N; j++) {
result = std::max(result, PSA[j] - (i == 0 ? 0 : PSA[i - 1]) - (P[j].first - P[i].first));
}
}
std::cout << result << std::endl;
}
Compilation message
art.cpp: In function 'int main()':
art.cpp:16:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
16 | for (auto& [a, b] : P) {
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
504 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
504 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
504 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
592 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
504 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
504 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
592 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
17 ms |
592 KB |
Output is correct |
28 |
Correct |
15 ms |
848 KB |
Output is correct |
29 |
Correct |
17 ms |
760 KB |
Output is correct |
30 |
Correct |
15 ms |
592 KB |
Output is correct |
31 |
Correct |
16 ms |
592 KB |
Output is correct |
32 |
Correct |
16 ms |
676 KB |
Output is correct |
33 |
Correct |
16 ms |
592 KB |
Output is correct |
34 |
Correct |
23 ms |
592 KB |
Output is correct |
35 |
Correct |
20 ms |
592 KB |
Output is correct |
36 |
Correct |
20 ms |
592 KB |
Output is correct |
37 |
Correct |
18 ms |
592 KB |
Output is correct |
38 |
Correct |
15 ms |
760 KB |
Output is correct |
39 |
Correct |
15 ms |
592 KB |
Output is correct |
40 |
Correct |
16 ms |
592 KB |
Output is correct |
41 |
Correct |
15 ms |
592 KB |
Output is correct |
42 |
Correct |
15 ms |
592 KB |
Output is correct |
43 |
Correct |
16 ms |
592 KB |
Output is correct |
44 |
Correct |
15 ms |
640 KB |
Output is correct |
45 |
Correct |
15 ms |
592 KB |
Output is correct |
46 |
Correct |
15 ms |
592 KB |
Output is correct |
47 |
Correct |
15 ms |
592 KB |
Output is correct |
48 |
Correct |
21 ms |
592 KB |
Output is correct |
49 |
Correct |
15 ms |
592 KB |
Output is correct |
50 |
Correct |
15 ms |
592 KB |
Output is correct |
51 |
Correct |
15 ms |
592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
1 ms |
504 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
504 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
592 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
336 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
336 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
17 ms |
592 KB |
Output is correct |
28 |
Correct |
15 ms |
848 KB |
Output is correct |
29 |
Correct |
17 ms |
760 KB |
Output is correct |
30 |
Correct |
15 ms |
592 KB |
Output is correct |
31 |
Correct |
16 ms |
592 KB |
Output is correct |
32 |
Correct |
16 ms |
676 KB |
Output is correct |
33 |
Correct |
16 ms |
592 KB |
Output is correct |
34 |
Correct |
23 ms |
592 KB |
Output is correct |
35 |
Correct |
20 ms |
592 KB |
Output is correct |
36 |
Correct |
20 ms |
592 KB |
Output is correct |
37 |
Correct |
18 ms |
592 KB |
Output is correct |
38 |
Correct |
15 ms |
760 KB |
Output is correct |
39 |
Correct |
15 ms |
592 KB |
Output is correct |
40 |
Correct |
16 ms |
592 KB |
Output is correct |
41 |
Correct |
15 ms |
592 KB |
Output is correct |
42 |
Correct |
15 ms |
592 KB |
Output is correct |
43 |
Correct |
16 ms |
592 KB |
Output is correct |
44 |
Correct |
15 ms |
640 KB |
Output is correct |
45 |
Correct |
15 ms |
592 KB |
Output is correct |
46 |
Correct |
15 ms |
592 KB |
Output is correct |
47 |
Correct |
15 ms |
592 KB |
Output is correct |
48 |
Correct |
21 ms |
592 KB |
Output is correct |
49 |
Correct |
15 ms |
592 KB |
Output is correct |
50 |
Correct |
15 ms |
592 KB |
Output is correct |
51 |
Correct |
15 ms |
592 KB |
Output is correct |
52 |
Execution timed out |
1062 ms |
24624 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |