Submission #507273

# Submission time Handle Problem Language Result Execution time Memory
507273 2022-01-12T10:25:26 Z CyberSleeper Potatoes and fertilizers (LMIO19_bulves) C++14
0 / 100
0 ms 308 KB
#include <bits/stdc++.h>
#define fastio      ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define debug(x)    cout << "Line " << __LINE__ << ", " << #x << " is " << x << endl
#define fi          first
#define se          second
#define mp          make_pair
#define pb          push_back
#define ll          long long
#define ull         unsigned long long
#define pii         pair<int, int>
#define pll         pair<ll, ll>
#define ld          long double
#define nl          '\n'
#define tb          '\t'
#define sp          ' '
using namespace std;

const int MX=500005, MOD=998244353, BLOCK=327, INF=1e9+7;
const ll INFF=1e18+7;
const ld ERR=1e-7, pi=3.14159265358979323846;

ll N, ans=INFF, A, B, tot, pref[MX], suff, DP[MX];

int main(){
    fastio;
    cin >> N;
    for(int i=1; i<=N; i++){
        cin >> A >> B;
        pref[i]=pref[i-1]+A-B;
        DP[i]=DP[i-1]+abs(pref[i]);
    }
    for(int i=N; i>0; i--){
        suff+=abs(pref[i]-1);
        ans=min(ans, DP[i-1]+suff);
    }
    cout << ans << nl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -