(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 #122844

#TimeUsernameProblemLanguageResultExecution timeMemory
122844nekiMeetings (IOI18_meetings)C++14
0 / 100
5529 ms38180 KiB
#include "meetings.h" #include <bits/stdc++.h> #define maxn 756000 #define loop(i, a, b) for(int i=a;i<b;i++) #define cc(a) cout<< a << endl; using namespace std; std::vector<int> he; struct seg{ int tree[maxn *2]; vector<int> pos[maxn *2]; void build(vector<int> arr){ loop(i, 0, arr.size()){ tree[i+maxn]=arr[i]; pos[i+maxn].push_back(i); } for(int i=maxn-1;i>0;i--){ if(tree[i]<tree[i *2]){tree[i]=tree[i *2];pos[i]=pos[i *2];} else if (tree[i]==tree[i *2]){pos[i].insert(pos[i].end(), pos[i *2].begin(), pos[i *2].end());} if(tree[i]<tree[i *2+1]){tree[i]=tree[i *2+1];pos[i]=pos[i *2+1];} else if (tree[i]==tree[i *2+1]){pos[i].insert(pos[i].end(), pos[i *2+1].begin(), pos[i *2+1].end());} } } vector<int> query(int l, int r){ vector<int> ret; int m=0; for(l+=maxn, r+=maxn;l<r;l>>=1, r>>=1){ if(l&1){ if(m<tree[l]){m=tree[l];ret=pos[l];} else if (m==tree[l]){ret.insert(ret.end(), pos[l].begin(), pos[l].end());} l++; } if(r&1){ r--; if(m<tree[r]){m=tree[r];ret=pos[r];} else if (m==tree[r]){ret.insert(ret.end(), pos[r].begin(), pos[r].end());} } } sort(ret.begin(), ret.end()); return ret; } }; seg re; long long solve(int l, int r){ vector<int> poses=re.query(l, r+1); if(l==r) return he[l]; int m=he[poses[0]]; poses.insert(poses.begin(), l-1);poses.push_back(r+1); long long ans=m*(r-l+1); loop(i, 1, poses.size()){ if(poses[i]==poses[i-1]+1) continue; ans=min(ans, solve(poses[i-1]+1, poses[i]-1)+(long long)m*(r-l+1-((poses[i]-1)-(poses[i-1]+1)+1))); } return ans; } std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L, std::vector<int> R) { re.build(H); he=H; vector<long long> ans; loop(i, 0, L.size()){ ans.push_back(solve(L[i], R[i])); } return ans; }

Compilation message (stderr)

meetings.cpp: In member function 'void seg::build(std::vector<int>)':
meetings.cpp:5:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define loop(i, a, b) for(int i=a;i<b;i++)
meetings.cpp:15:14:
         loop(i, 0, arr.size()){
              ~~~~~~~~~~~~~~~~       
meetings.cpp:15:9: note: in expansion of macro 'loop'
         loop(i, 0, arr.size()){
         ^~~~
meetings.cpp: In function 'long long int solve(int, int)':
meetings.cpp:5:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define loop(i, a, b) for(int i=a;i<b;i++)
meetings.cpp:56:10:
     loop(i, 1, poses.size()){
          ~~~~~~~~~~~~~~~~~~         
meetings.cpp:56:5: note: in expansion of macro 'loop'
     loop(i, 1, poses.size()){
     ^~~~
meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:5:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define loop(i, a, b) for(int i=a;i<b;i++)
meetings.cpp:69:10:
     loop(i, 0, L.size()){
          ~~~~~~~~~~~~~~             
meetings.cpp:69:5: note: in expansion of macro 'loop'
     loop(i, 0, L.size()){
     ^~~~
#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...