Submission #419406

#TimeUsernameProblemLanguageResultExecution timeMemory
419406TricksterArt Exhibition (JOI18_art)C++14
0 / 100
1 ms204 KiB
//Suleyman Atayew #include <algorithm> #include <iostream> #include <string.h> #include <stdio.h> #include <vector> #include <bitset> #include <queue> #include <cmath> #include <map> #include <set> #define N 200010 #define ff first #define ss second #define pb push_back #define ll long long #define mod 1000000007 #define pii pair <ll, ll> #define sz(a) (ll)(a.size()) ll bigmod(ll a, ll b) { if(b==0)return 1; ll ret = bigmod(a, b/2); return ret * ret % mod * (b%2 ? a : 1) % mod; } using namespace std; ll n; pii p[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; ll sum = 0, ans = 0; for(ll i = 1; i <= n; i++) { cin >> p[i].ff >> p[i].ss; ans = max(ans, p[i].ss); } sort(p+1, p+n+1); queue <ll> Q; for(ll i = 1; i <= n; i++) { sum = sum + p[i].ss - (i != 1 ? p[i].ff - p[i-1].ff : 0); ans = max(ans, sum); while(!Q.empty() && sum < 0) { ll x = Q.front(); sum = sum - p[x].ss + (p[x+1].ff - p[x].ff); Q.pop(); } Q.push(i); ans = max(ans, sum); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...