#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,bmi,bmi2")
#define all(a) a.begin(),a.end()
using namespace std;
#define int long long
void gogo() {
int n;
cin >> n;
pair<int, int>seg[n + 1];
for (int i = 1; i <= n; i++) {
cin >> seg[i].first >> seg[i].second;
}
sort(seg + 1, seg + n + 1);
int ans = 0;
for (int l = 1; l <= n; l++) {
int sum = 0;
for (int r = l; r <= n && r <= l + 5; r++) {
sum += seg[r].second;
ans = max(ans, sum + seg[l].first - seg[r].first);
}
}
cout << ans << endl;
}
main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
// cin >> t;
while (t--) {
gogo();
}
}
컴파일 시 표준 에러 (stderr) 메시지
art.cpp:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
25 | main() {
| ^~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |