Submission #823309

#TimeUsernameProblemLanguageResultExecution timeMemory
823309Dremix10Meetings (IOI18_meetings)C++17
0 / 100
5540 ms1492 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; #define F first #define S second #define all(x) (x).begin(),(x).end() typedef long long ll; typedef pair<int,int> pi; typedef pair<ll,ll> pl; const int N = 3e5+5; const ll INF = 1e18+5; const int MOD = 1e9+7; vector<long long> minimum_costs(vector<int> arr, vector<int> L, vector<int> R) { int n = arr.size(); int q = L.size(); int i,j,k; vector<ll> ans(q); for(k=0;k<q;k++){ int x = L[k]; int y = R[k]; ll res = INF; for(i=x;i<=y;i++){ // good i is always local minima if(i-1 >= 0 && arr[i-1] < arr[i])continue; if(i+1 < n && arr[i+1] < arr[i])continue; ll curr = 0; int maxi = 0; for(j=i;j<=y;j++){ maxi = max(maxi,arr[j]); curr += maxi; } maxi = arr[i]; for(j=i-1;j>=x;j--){ maxi = max(maxi,arr[j]); curr += maxi; } res = min(res,curr); } ans[k] = res; } return ans; }
#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...