Submission #1144618

#TimeUsernameProblemLanguageResultExecution timeMemory
1144618zhasynArt Exhibition (JOI18_art)C++20
50 / 100
1096 ms8704 KiB
#include <bits/stdc++.h> #define pb push_back #define pf push_front using namespace std; #define F first #define S second typedef long long ll; #define pii pair <int, int> #define pll pair <ll, ll> typedef long double ld; const ll N = 5 * 1e5 + 100, M = 4096 + 10, len = 21, inf = 1e18; const ll mod = 1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ll um(ll a, ll b){ return (1LL * a * b) % mod; } ll subr(ll a, ll b){ return ((1LL * a - b) % mod + mod) % mod; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); ll n, ans = 0; cin >> n; vector <pll> vec; for(ll i = 0, a, b; i < n; i++){ cin >> a >> b; vec.pb({a, b}); } sort(vec.begin(), vec.end()); for(ll i = 0; i < n; i++){ ll sum = 0; for(ll j = i; j < n; j++){ sum += vec[j].S; ans = max(ans, sum - (vec[j].F - vec[i].F)); } } 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...