제출 #790527

#제출 시각아이디문제언어결과실행 시간메모리
790527n3rm1nArt Exhibition (JOI18_art)C++17
50 / 100
1062 ms32540 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; const long long MAXN = 5e5 + 10; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } long long n; vector < pair < long long , long long > > g; long long a[MAXN], b[MAXN]; long long p[MAXN]; void read() { cin >> n; g.push_back(make_pair(-1, -1)); for (long long i = 1; i <= n; ++ i) cin >> a[i] >> b[i]; for (long long i = 1; i <= n; ++ i) { g.push_back(make_pair(a[i], b[i])); } sort(g.begin(), g.end()); for (long long i = 1; i <= n; ++ i) { p[i] = p[i-1] + g[i].second; } } void solve() { long long ans = -1e17; for (int i = 1; i <= n; ++ i) { for (int j = 1; j <= i; ++ j) { ans = max(ans, - (g[i].first - g[j].first) + p[i] - p[j-1]); } } cout << ans << endl; } int main() { speed(); read(); 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...