# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1234804 | Jer | Art Exhibition (JOI18_art) | C++20 | 0 ms | 320 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 5e5 + 5;
int n;
pair<ll, ll> a[MAXN];
ll pre[MAXN];
#define ff first
#define ss second
int main()
{
scanf("%d", &n);
ll f, s;
for (int i = 0; i < n; i++)
scanf("%lld%lld", &f, &s), a[i] = {f, s};
sort(a, a + n);
for (int i = 0; i < n; i++)
pre[i] = (i == 0) ? a[i].ss : a[i].ss + pre[i - 1];
ll res = 0;
for (int j = 0; j < n; j++)
{
ll sum = pre[j];
res = max(res, sum - (a[j].ff - a[0].ff));
}
printf("%lld\n", res);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |