Submission #916765

#TimeUsernameProblemLanguageResultExecution timeMemory
916765a_l_i_r_e_z_aArt Exhibition (JOI18_art)C++17
100 / 100
143 ms21076 KiB
// In the name of God // Hope is last to die #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define pb push_back #define S second #define F first #define mp make_pair #define smax(x, y) (x) = max((x), (y)) #define smin(x, y) (x) = min((x), (y)) #define all(x) (x).begin(), (x).end() #define len(x) ((int)(x).size()) const int maxn = 5e5 + 5; const int inf = 1e9 + 7; int n; pll a[maxn]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i = 0; i < n; i++) cin >> a[i].F >> a[i].S; sort(a, a + n); ll ans = 0, res = a[0].F; for(int i = 0; i < n; i++){ smax(ans, res + a[i].S - a[i].F); smax(ans, a[i].S); res = max(res + a[i].S, a[i].F + a[i].S); } cout << ans << '\n'; 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...