Submission #794131

#TimeUsernameProblemLanguageResultExecution timeMemory
794131NothingXDMeetings (IOI18_meetings)C++17
19 / 100
730 ms216136 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef double ld; typedef complex<ld> point; void debug_out(){cerr << endl;} template<typename Head, typename... Tail> void debug_out(Head H, Tail... T){ cerr << H << ' '; debug_out(T...); } #define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__) #define F first #define S second #define all(x) x.begin(), x.end() #define MP(x, y) make_pair(x, y) const int maxn = 5e3 + 10; int n, q; ll h[maxn]; ll val[maxn][maxn][2]; vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) { n = H.size(); q = L.size(); for (int i = 0; i < n; i++){ h[i] = H[i]; } for (int i = 0; i < n; i++){ val[i][i][0] = val[i][i][1] = h[i]; for (int j = i+1; j < n; j++){ val[i][j][0] = max(val[i][j-1][0], h[j]); } for (int j = i+1; j < n; j++){ val[i][j][0] += val[i][j-1][0]; //debug(i, j, val[i][j][0]); } for (int j = i-1; ~j; j--){ val[j][i][1] = max(val[j+1][i][1], h[j]); } for (int j = i-1; ~j; j--){ val[j][i][1] += val[j+1][i][1]; // debug(i, j, val[i][j][1]); } } vector<ll> res; for (int i = 0; i < q; i++){ ll ans = 1e18; for (int j = L[i]; j <= R[i]; j++){ ans = min(ans, val[j][R[i]][0] + val[L[i]][j][1] - h[j]); } res.push_back(ans); } return res; }
#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...