Submission #291642

#TimeUsernameProblemLanguageResultExecution timeMemory
291642TheLoraxMeetings (IOI18_meetings)C++11
4 / 100
5549 ms2424 KiB
#include <bits/stdc++.h> #include "meetings.h" #define F first #define S second #define SZ(a) ((int)(a).size()) #define PB push_back #define ALL(a) (a).begin(), (a).end() using namespace std; typedef long long ll; typedef pair<ll, ll> ii; std::vector<long long> minimum_costs(std::vector<int> h, std::vector<int> l, std::vector<int> r) { int q = SZ(l), n=SZ(h); std::vector<long long> c(q); for(int i=0; i<q; i++){ std::vector<ll> a(r[i]-l[i]+1), b(r[i]-l[i]+1); map<ll,ll> ma, mb; for(int j=l[i]; j<=r[i]; j++){ ma[h[j]]++; a[j-l[i]]=(j>l[i]?a[j-l[i]-1]:0)+h[j]; while (ma.begin()->F!=h[j]) { ma[h[j]]+=ma.begin()->S; a[j-l[i]]+=h[j]*ma.begin()->S; a[j-l[i]]-=ma.begin()->F*ma.begin()->S; ma.erase(ma.begin()->F); } } for(int j=r[i]; j>=l[i]; j--){ mb[h[j]]++; b[j-l[i]]=(j<r[i]?b[j-l[i]+1]:0)+h[j]; while (mb.begin()->F!=h[j]) { mb[h[j]]+=mb.begin()->S; b[j-l[i]]+=h[j]*mb.begin()->S; b[j-l[i]]-=mb.begin()->F*mb.begin()->S; mb.erase(mb.begin()->F); } } for(int j=0; j<r[i]-l[i]+1; j++){ // fprintf(stderr, "%lld %lld\n", a[j], b[j]); a[j]+=b[j]-h[j+l[i]]; } sort(ALL(a)); c[i]=a[0]; } return c; }

Compilation message (stderr)

meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:18:18: warning: unused variable 'n' [-Wunused-variable]
   18 |   int q = SZ(l), n=SZ(h);
      |                  ^
#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...