제출 #1220014

#제출 시각아이디문제언어결과실행 시간메모리
1220014jellybeanArt Exhibition (JOI18_art)C++20
100 / 100
112 ms15956 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second typedef pair<int,int> pii; const int N = 5e5+5; int s[N], v[N], p[N], dp[N]; pii arr[N]; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin>>n; for(int i=1; i<=n; i++){ int a,b; cin>>a>>b; arr[i] = {a,b}; } sort(arr+1, arr+1+n); for(int i=1; i<=n; i++) p[i] = p[i-1] + arr[i].se; int mi = -arr[1].fi; for(int i=1; i<=n; i++){ dp[i] = p[i] - arr[i].fi - mi; mi = min(mi, p[i]-arr[i+1].fi); } int ans = 0; for(int i=1; i<=n; i++) ans = max(ans, dp[i]); cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...