Submission #292574

#TimeUsernameProblemLanguageResultExecution timeMemory
292574AKaan37Meetings (IOI18_meetings)C++17
4 / 100
5613 ms786432 KiB
#include "meetings.h" #include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC target ("sse4") using namespace std; typedef long long lo; typedef pair< lo,lo > PII; #define fi first #define se second #define mp make_pair #define endl "\n" #define pb push_back #define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR for(int i=1;i<=n;i++) #define mid ((start+end)/2) #define ort ((bas+son)/2) const lo inf = 1000000000000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 5003; const lo mod = 1000000007; lo n,t,tree[li][li*4],ind; lo cev; int a[li][li]; inline void build(int node,int start,int end){ if(start==end){tree[ind][node]=a[ind][start-1];return ;} build(node*2,start,mid),build(node*2+1,mid+1,end); tree[ind][node]=tree[ind][node*2]+tree[ind][node*2+1]; } inline lo query(int node,int start,int end,int l,int r){ if(start>end || start>r || end<l)return 0; if(start>=l && end<=r){return tree[ind][node];} return query(node*2,start,mid,l,r)+query(node*2+1,mid+1,end,l,r); } std::vector<long long> minimum_costs(vector<int> h,vector<int> l,vector<int> r) { t = (int)l.size(); n=(int)h.size(); for(int i=0;i<n;i++){ int mx=0; for(int j=i;j>=0;j--){ mx=max(mx,h[j]); a[i][j]=mx; } mx=0; for(int j=i;j<n;j++){ mx=max(mx,h[j]); a[i][j]=mx; } } for(int i=0;i<n;i++){ ind=i; build(1,1,n); } vector<lo> v; for(int i=0;i<t;i++){ cev=inf; l[i]++; r[i]++; for(int j=l[i];j<=r[i];j++){ ind=j-1; lo at=0,at1=0; if(l[i]<=j && l[i]<=n)at=query(1,1,n,l[i],min((lo)n,(lo)j)); if(j+1<=n && j+1<=r[i])at1=query(1,1,n,j+1,min((lo)n,(lo)r[i])); cev=min(cev,at+at1); } v.pb(cev); } return v; }
#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...