Submission #3010256


Source Code Expand

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll pref[211111];
ll x[211111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]>>pref[i];
	}
	for(int i=1;i<=n;i++)
	{
		pref[i]+=pref[i-1];
	}
	ll ans=0; ll mini=pref[0]-x[1];
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,pref[i]-x[i]-mini);
		if(i<n) mini=min(mini,pref[i]-x[i+1]);
	}
	cout<<ans<<'\n';
}

Submission Info

Submission Time
Task F - Capture
User fxt
Language C++ (GCC 5.4.1)
Score 100
Code Size 985 Byte
Status AC
Exec Time 47 ms
Memory 3456 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 33
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
b04 AC 1 ms 256 KB
b05 AC 47 ms 3328 KB
b06 AC 47 ms 3456 KB
b07 AC 32 ms 3328 KB
b08 AC 34 ms 3456 KB
b09 AC 32 ms 3456 KB
b10 AC 38 ms 3328 KB
b11 AC 39 ms 3328 KB
b12 AC 38 ms 3456 KB
b13 AC 38 ms 3328 KB
b14 AC 39 ms 3328 KB
b15 AC 37 ms 3456 KB
b16 AC 37 ms 3328 KB
b17 AC 37 ms 3456 KB
b18 AC 46 ms 3328 KB
b19 AC 35 ms 3456 KB
b20 AC 44 ms 3456 KB
b21 AC 46 ms 3328 KB
b22 AC 46 ms 3328 KB
b23 AC 46 ms 3328 KB
b24 AC 38 ms 3328 KB
b25 AC 38 ms 3456 KB
b26 AC 37 ms 3328 KB
b27 AC 38 ms 3456 KB
b28 AC 37 ms 3328 KB
b29 AC 37 ms 3328 KB
b30 AC 47 ms 3456 KB
b31 AC 35 ms 3456 KB
b32 AC 47 ms 3328 KB
b33 AC 46 ms 3456 KB