Submission #972885

#TimeUsernameProblemLanguageResultExecution timeMemory
972885kwongwengMeetings (IOI18_meetings)C++17
19 / 100
3859 ms786432 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long double ld; typedef vector<vector<ll>> vll; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) #define pb push_back #define ms memset #define fi first #define se second vector<ll> minimum_costs(vi H, vi L, vi R) { int n = H.size(); int q = R.size(); ll val[n][n]; ms(val,0,sizeof(val)); FOR(i,0,n){ val[i][i] = H[i]; int mx = H[i]; FOR(j,i+1,n){ mx = max(mx,H[j]); val[i][j] = val[i][j-1] + mx; } mx=H[i]; ROF(j,i-1,0){ mx=max(mx,H[j]); val[i][j] = val[i][j+1] + mx; } } vector<ll> answer(q); FOR(i,0,q){ answer[i] = 1e18; FOR(j,L[i],R[i]+1){ answer[i]=min(answer[i],val[j][L[i]]+val[j][R[i]]-H[j]); } } return answer; }
#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...