이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define int long long
#define N 500005
#define pii pair<int, int>
using namespace std;
int n, i, j, mx, ans, dp[N];
pii a[N];
main()
{
std::ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(i = 0; i < n; i++)
cin >> a[i].f >> a[i].s;
sort(a, a + n);
dp[0] = a[0].s;
for(i = 1; i < n; i++)
{
dp[i] = max(a[i].s, dp[i - 1] + a[i - 1].f + a[i].s - a[i].f);
ans = max(ans, dp[i]);
}
cout << ans << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
art.cpp:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
13 | 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... |