# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
973110 | 2024-05-01T13:49:59 Z | hihihah | Potatoes and fertilizers (LMIO19_bulves) | C++14 | 134 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[500009]; 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]; } vector<vector<int64_t>> dp(n + 3, vector<int64_t>(pre[n] + 3, 0)); for(int i = 1; i <= n; i ++) { for(int j = 0; j <= pre[n]; 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 1 ms | 4700 KB | Output is correct |
3 | Correct | 2 ms | 4700 KB | Output is correct |
4 | Correct | 11 ms | 9692 KB | Output is correct |
5 | Correct | 16 ms | 12892 KB | Output is correct |
6 | Correct | 45 ms | 24148 KB | Output is correct |
7 | Correct | 84 ms | 42416 KB | Output is correct |
8 | Correct | 73 ms | 40528 KB | Output is correct |
9 | Correct | 79 ms | 39868 KB | Output is correct |
10 | Correct | 73 ms | 37456 KB | Output is correct |
11 | Correct | 69 ms | 37456 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 1 ms | 4700 KB | Output is correct |
3 | Correct | 2 ms | 4700 KB | Output is correct |
4 | Correct | 11 ms | 9692 KB | Output is correct |
5 | Correct | 16 ms | 12892 KB | Output is correct |
6 | Correct | 45 ms | 24148 KB | Output is correct |
7 | Correct | 84 ms | 42416 KB | Output is correct |
8 | Correct | 73 ms | 40528 KB | Output is correct |
9 | Correct | 79 ms | 39868 KB | Output is correct |
10 | Correct | 73 ms | 37456 KB | Output is correct |
11 | Correct | 69 ms | 37456 KB | Output is correct |
12 | Correct | 24 ms | 17244 KB | Output is correct |
13 | Correct | 54 ms | 32592 KB | Output is correct |
14 | Correct | 96 ms | 50260 KB | Output is correct |
15 | Correct | 92 ms | 48212 KB | Output is correct |
16 | Correct | 78 ms | 47620 KB | Output is correct |
17 | Correct | 64 ms | 45320 KB | Output is correct |
18 | Correct | 1 ms | 4700 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 1 ms | 4700 KB | Output is correct |
3 | Correct | 1 ms | 4700 KB | Output is correct |
4 | Correct | 1 ms | 4440 KB | Output is correct |
5 | Correct | 13 ms | 20316 KB | Output is correct |
6 | Correct | 46 ms | 63332 KB | Output is correct |
7 | Runtime error | 134 ms | 262144 KB | Execution killed with signal 9 |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 1 ms | 4700 KB | Output is correct |
3 | Correct | 2 ms | 4700 KB | Output is correct |
4 | Correct | 1 ms | 4440 KB | Output is correct |
5 | Correct | 13 ms | 20316 KB | Output is correct |
6 | Correct | 46 ms | 63332 KB | Output is correct |
7 | Runtime error | 134 ms | 262144 KB | Execution killed with signal 9 |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 1 ms | 4700 KB | Output is correct |
3 | Correct | 2 ms | 4700 KB | Output is correct |
4 | Correct | 1 ms | 4440 KB | Output is correct |
5 | Correct | 13 ms | 20316 KB | Output is correct |
6 | Correct | 46 ms | 63332 KB | Output is correct |
7 | Runtime error | 134 ms | 262144 KB | Execution killed with signal 9 |
8 | Halted | 0 ms | 0 KB | - |