제출 #913880

#제출 시각아이디문제언어결과실행 시간메모리
913880dm2010Art Exhibition (JOI18_art)C++14
100 / 100
400 ms12240 KiB
#include <bits/stdc++.h> using namespace std; int main() { long long a,maxx=0; cin >> a; pair <long long, long long> p[a]; for (int i=0;i<a;i++) cin >> p[i].first >> p[i].second; sort(p,p+a); long long x[a]; x[0]=p[0].second; for (int i=1;i<a;i++) { x[i]=x[i-1]+p[i].second; } long long mx = p[0].first; for(int j=0;j<a;j++) { //x[j]-p[j].first + (p[i].first - x[i - 1]) maxx = max(maxx, x[j]-p[j].first + mx); mx = max(mx, p[j+1].first - x[j]); } cout << maxx <<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...