Submission #973110

#TimeUsernameProblemLanguageResultExecution timeMemory
973110hihihahPotatoes and fertilizers (LMIO19_bulves)C++14
34 / 100
134 ms262144 KiB
#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 (stderr)

bulves.cpp: In function 'int32_t main()':
bulves.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         freopen(orz".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...