# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
79039 | doowey | 모임들 (IOI18_meetings) | C++14 | 731 ms | 398684 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "meetings.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5005;
ll meet[N][N];
ll pref(int dim, int l, int r){
ll ans = meet[dim][r];
if(l != 0)
ans -= meet[dim][l - 1];
return ans;
}
vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) {
int n = H.size();
int mx;
for(int i = 0 ;i < n; i ++ ){
meet[i][i] = H[i];
mx = H[i];
for(int j = i - 1; j >= 0; j -- ){
mx = max(mx, H[j]);
meet[i][j] = mx;
}
mx = H[i];
for(int j = i + 1; j < n; j ++ ){
mx = max(mx, H[j]);
meet[i][j] = mx;
}
}
for(int i = 0 ; i < n; i ++ ){
for(int j = 1; j < n; j ++ ){
meet[i][j] += meet[i][j - 1];
}
}
vector<ll> ans;
int lf, rf;
ll tot;
for(int i = 0; i < L.size(); i ++ ){
lf = L[i];
rf = R[i];
tot = (ll)1e18;
for(int j = lf; j <= rf; j ++ ){
tot = min(tot, pref(j, lf, rf));
}
ans.push_back(tot);
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |