제출 #1326721

#제출 시각아이디문제언어결과실행 시간메모리
1326721saleh_musudluArt Exhibition (JOI18_art)C++20
100 / 100
207 ms15956 KiB
#include <bits/stdc++.h> using namespace std; const long long MAX = 5e5 + 5; pair<long long, long long> a[MAX]; long long pref[MAX], dp[MAX]; void solve() { long long n; cin >> n; for (long long i = 1; i <= n; i++) cin >> a[i].first, cin >> a[i].second; sort(a + 1, a + n + 1); for (long long i = 1; i <= n; i++) pref[i] = pref[i - 1] + a[i].second; for (long long i = 1; i <= n; i++) { dp[i] = max(a[i].second, dp[i - 1] + a[i].second - (a[i].first - a[i - 1].first)); } long long mx = -1; for (long long i = 1; i <= n; i++) mx = max(dp[i], mx); cout << mx; } int main() { ios::sync_with_stdio(0); cin.tie(0); long long tt = 1; // cin >> tt; while (tt--) solve(); 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...