Submission #508371

# Submission time Handle Problem Language Result Execution time Memory
508371 2022-01-13T09:39:31 Z CyberSleeper Potatoes and fertilizers (LMIO19_bulves) C++14
0 / 100
223 ms 262148 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=3005, MOD=998244353, BLOCK=327, INF=1e9+7;
const ll INFF=1e18+7;
const ld ERR=1e-7, pi=3.14159265358979323846;

ll N, A, pref[MX], DP[MX][30005];

int main(){
    fastio;
    cin >> N;
    for(int i=1; i<=N; i++){
        ll a, b;
        cin >> a >> b;
        A+=a-b;
        for(int j=0; j<=30000; j++){
            DP[i][j]=DP[i-1][j]+abs(j-A);
            if(j)
                DP[i][j]=min(DP[i][j], DP[i][j-1]);
        }
    }
    cout << DP[N][A] << nl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1740 KB Output is correct
2 Runtime error 223 ms 262148 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1740 KB Output is correct
2 Runtime error 223 ms 262148 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1740 KB Output is correct
2 Runtime error 223 ms 262148 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1740 KB Output is correct
2 Runtime error 223 ms 262148 KB Execution killed with signal 9
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1740 KB Output is correct
2 Runtime error 223 ms 262148 KB Execution killed with signal 9