이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll pair <long long,long long>
using namespace std;
ll a[1000002];
long long oo=100000000000000000;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
for (int i=1;i<=n;i++)
{
cin >> a[i].first >> a[i].second;
}
sort (a+1,a+1+n);
int i2=1;
long long tong=0;
long long kq=0-oo;
for (int i=1;i<=n;i++)
{
tong=tong+a[i].second;
while ((i2<i) and (a[i2+1].first-a[i2].first>a[i2].second))
{
tong=tong-a[i2].second;
i2++;
}
kq=max(kq,tong-(a[i].first-a[i2].first));
// cout << i << " " << i2 << " " << tong-(a[i].first-a[i2].first) << '\n';
}
cout << kq;
}
| # | 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... |