Submission #6003590


Source Code Expand

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll n;
    cin >> n;
    VL x(n), a(n);
    REP(i,n){
        x[i] = lin();
        a[i] = lin();
    }
    VL s(n + 1);
    REP(i,n) s[i + 1] = s[i] + a[i];

    ll ans = 0, mi = 1e18;
    REP(i,n){
        chmin(mi, s[i] - x[i]);
        chmax(ans, s[i + 1] - x[i] - mi);
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task F - Capture
User TangentDay
Language C++14 (GCC 5.4.1)
Score 100
Code Size 1296 Byte
Status AC
Exec Time 56 ms
Memory 4992 KB

Compile Error

./Main.cpp: In function ‘int in()’:
./Main.cpp:36:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 int in() { int x; scanf("%d", &x); return x; }
                                  ^
./Main.cpp: In function ‘ll lin()’:
./Main.cpp:37:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 ll lin() { ll x; scanf("%lld", &x); return x; }
                                   ^

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 55 ms 4992 KB
b06 AC 55 ms 4992 KB
b07 AC 40 ms 4992 KB
b08 AC 40 ms 4992 KB
b09 AC 40 ms 4992 KB
b10 AC 46 ms 4992 KB
b11 AC 46 ms 4992 KB
b12 AC 46 ms 4992 KB
b13 AC 46 ms 4992 KB
b14 AC 46 ms 4992 KB
b15 AC 45 ms 4992 KB
b16 AC 45 ms 4992 KB
b17 AC 45 ms 4992 KB
b18 AC 54 ms 4992 KB
b19 AC 44 ms 4992 KB
b20 AC 54 ms 4992 KB
b21 AC 54 ms 4992 KB
b22 AC 54 ms 4992 KB
b23 AC 54 ms 4992 KB
b24 AC 46 ms 4992 KB
b25 AC 45 ms 4992 KB
b26 AC 45 ms 4992 KB
b27 AC 46 ms 4992 KB
b28 AC 45 ms 4992 KB
b29 AC 45 ms 4992 KB
b30 AC 56 ms 4992 KB
b31 AC 43 ms 4992 KB
b32 AC 55 ms 4992 KB
b33 AC 54 ms 4992 KB