# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973104 | 2024-05-01T13:47:19 Z | hihihah | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 236 ms | 262144 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long #define all(x) x.begin(), x.end() #define pii pair<int, int> int n; int a[500009]; int b[500009]; int64_t pre[5000009]; int64_t dp[3009][30009]; void hihihah() { cin >> n; for(int i = 1; i <= n; i ++) cin >> a[i] >> b[i]; for(int i = 1; i <= n; i ++) { pre[i] = pre[i - 1] + a[i] - b[i]; } for(int i = 1; i <= n; i ++) { for(int j = 0; j <= 30000; j ++) { dp[i][j] = dp[i - 1][j] + abs(j - pre[i]); if(j > 0) dp[i][j] = min(dp[i][j - 1], dp[i][j]); } } cout << dp[n][pre[n]]; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define orz "mo" if(fopen(orz".inp", "r")) { freopen(orz".inp", "r", stdin); // freopen(orz".out", "w", stdout); } int t = 1; // cin >> t; while(t --) { hihihah(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6488 KB | Output is correct |
2 | Runtime error | 236 ms | 262144 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6488 KB | Output is correct |
2 | Runtime error | 236 ms | 262144 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6488 KB | Output is correct |
2 | Runtime error | 236 ms | 262144 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6488 KB | Output is correct |
2 | Runtime error | 236 ms | 262144 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 6488 KB | Output is correct |
2 | Runtime error | 236 ms | 262144 KB | Execution killed with signal 9 |
3 | Halted | 0 ms | 0 KB | - |