이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define ll long long
#define ii pair<ll, ll>
#define vhg ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pp pair <long long,long long>
using namespace std;
//------------------------------------
pp a[5000002];
long long oo=1e18;
//----------------------------------------
int main(){
vhg;
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++){
if (tong<a[i].first-a[i2].first){
tong=0;
i2=i;
}
tong=tong+a[i].second;
kq=max(kq,tong-(a[i].first-a[i2].first));
}
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... |