# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
699548 | Galal012 | Art Exhibition (JOI18_art) | C++17 | 1 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
using namespace std;
signed main()
{
IOS;
int n, ans = 0, l = 1, r = 1, cur = -1;
cin >> n;
pair <int, int> pr[n+1];
pr[0].first = pr[0].second = 0;
for (int i = 1; i <= n; i++)
{
cin >> pr[i].first >> pr[i].second;
ans = max(ans, pr[i].second);
}
sort(pr, pr+n+1);
for (int i = 1; i <= n; i++)
pr[i].second += pr[i-1].second;
while (l <= n && r <= n)
{
cout << l << " " << r << "\n";
int tot = pr[r].second - pr[l-1].second;
int dif = pr[r].first-pr[l].first;
ans = max(ans, tot-dif);
if (l == r)
{
cur = pr[r].second-pr[l-1].second;
r++;
}
else if (r == n)
l++;
else
{
int n_tot = pr[r+1].second - pr[l-1].second;
int n_dif = pr[r+1].first-pr[l].first;
if (n_tot - n_dif >= tot-dif)
{
cur = n_tot-n_dif;
r++;
}
else
{
l++;
cur = (pr[r].second - pr[l-1].second) - (pr[r].first-pr[l].first);
}
}
}
cout << ans;
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... |