Submission #1029622

#TimeUsernameProblemLanguageResultExecution timeMemory
1029622mindiyakMeetings (IOI18_meetings)C++14
19 / 100
2200 ms786432 KiB
#include "meetings.h" #pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops") #include <bits/stdc++.h> #include <string> #include <iostream> #include <cmath> #include <numeric> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pi; typedef pair<int, int> pl; typedef pair<ld, ld> pd; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<vector<int>> vvi; typedef vector<ld> vd; typedef vector<ll> vl; typedef vector<pi> vpi; typedef vector<pl> vpl; #define FOR(i, a, b) for (int i = a; i < (b); i++) #define F0R(i, a) for (int i = 0; i < (a); i++) #define FORd(i, a, b) for (int i = (b)-1; i >= a; i--) #define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--) #define trav(a, x) for (auto &a : x) #define uid(a, b) uniform_int_distribution<int>(a, b)(rng) #define len(x) (int)(x).size() #define mp make_pair #define pb push_back #define F first #define nl endl #define S second #define lb lower_bound #define ub upper_bound #define aint(x) x.begin(), x.end() #define raint(x) x.rbegin(), x.rend() #define ins insert const int MOD = 1000000007; vi arr(5e6,0),H; void build(int pos,int l,int r){ if(l == r){ arr[pos] = H[l]; return; } int mid = (l+r)/2; build(2*pos+1,l,mid); build(2*pos+2,mid+1,r); arr[pos] = max(arr[2*pos+1],arr[2*pos+2]); } int check(int pos,int l,int r,int ql,int qr){ if(ql>r||qr<l)return 0; if(ql<=l && r<=qr)return arr[pos]; int mid = (l+r)/2; return max(check(2*pos+1,l,mid,ql,qr),check(2*pos+2,mid+1,r,ql,qr)); } vl minimum_costs(vi h, vi L,vi R) { vi H = h; int N = H.size(); // build(0,0,n-1); vector<vl> counter(N,vl(N,0)); FOR(j,0,N){ ll temp = H[j]; int cur = H[j]; counter[j][j] = 0; temp = 0; for(int k = j-1;k>=0;k--){ cur = max(H[k],cur); temp += cur; counter[j][k] = temp; } cur = H[j]; temp = 0; for(int k = j+1;k<N;k++){ cur = max(H[k],cur); temp += cur; counter[j][k] = temp; } } int Q = L.size(); vl C(Q); FOR(i,0,Q){ ll ans = 1e18; FOR(j,L[i],R[i]+1){ ll temp = H[j] + counter[j][L[i]] + counter[j][R[i]]; ans = min(ans,temp); } C[i] = ans; } return C; }
#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...