이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <sstream>
using namespace std;
#define accepted ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define Daulbekov signed
#define Makan main
#define int long long
#define double long double
#define pb push_back
#define pf push_front
#define F first
#define S second
const int N=1e5+7;
const int MAX=9e18+7;
const int INF=1e18;
Daulbekov Makan(){
int n;
cin>>n;
pair<int,int>a[n];
for(int i=0;i<n;i++)cin>>a[i].F>>a[i].S;
sort(a,a+n);
int mx=a[0].S,col=a[0].S;
bool b=1;
for(int i=1;i<n;i++){
if(b==0){
b=1;
col+=a[i].S;
mx=max(mx,col);
continue;
}
col+=a[i].S;
col-=(a[i].F-a[i-1].F);
if(col<0){
col=0;
b=0;
}
mx=max(mx,col);
}
cout<<mx;
}
// 2 3
// 4 5
// 11 2
| # | 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... |