# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
918516 | 2024-01-30T03:43:00 Z | Cutebol | Art Exhibition (JOI18_art) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> #define int long long using namespace std ; int main (){ int n ; cin >> n ; pair <int , int> a[n+5] ; for ( int i = 0 ; i < n ; i ++ ) cin >> a[i].first >> a[i].second ; sort ( a , a + n ) ; int pref = 0 , ans = 0 ; for ( int i = 0 ; i < n ; i ++ ){ pref += a[i].second ; pref = max ( pref , a[i].second + a[i].first ) ; ans = max ( ans , pref-a[i].first ) ; } cout << ans ; }