(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #140414

#TimeUsernameProblemLanguageResultExecution timeMemory
140414arthurconmyMeetings (IOI18_meetings)C++14
19 / 100
3597 ms398288 KiB
#include <bits/stdc++.h> #ifndef ARTHUR_LOCAL #include "meetings.h" #endif using namespace std; using ll = long long; const int p2 = 2*4096; const int MAXN = 5000; int max_segtree[p2+p2]; ll sum_arr[MAXN][MAXN+1]; int RMQ(int l, int r) { l += p2; r += p2; if(l>r) swap(l,r); int ans=0; while(l<=r) { if(l%2 == 1) ans=max(ans,max_segtree[l++]); if(r%2 == 0) ans=max(ans,max_segtree[r--]); l/=2; r/=2; } return ans; } vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) { // int Q = L.size(); // std::vector<long long> C(Q); // for (int j = 0; j < Q; ++j) { // C[j] = H[L[j]]; // } // return C; int q = L.size(); int n = H.size(); for(int i=0; i<n; i++) { max_segtree[i+p2]=H[i]; } for(int i=p2-1; i>=1; i--) { max_segtree[i]=max(max_segtree[i+i],max_segtree[i+i+1]); } for(int i=0; i<n; i++) { for(int j=0; j<n; j++) { // sum_segtree[i][j+p2]=ll(RMQ(i,j)); sum_arr[i][j+1] = sum_arr[i][j] + ll(RMQ(i,j)); } } vector<ll> ans; for(int i=0; i<q; i++) { ll cur = 1e18; for(int j=L[i]; j<=R[i]; j++) { cur = min(cur, sum_arr[j][R[i]+1] - sum_arr[j][L[i]]); //cout << i << " " << j << " " << query(i,L[i],R[i]) << endl; } ans.push_back(cur); } return ans; } #ifdef ARTHUR_LOCAL int main() { for(auto e:minimum_costs({2,4,3,5},{0,1},{2,3})) { cout << e << endl; } } #endif
#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...