Submission #587712

#TimeUsernameProblemLanguageResultExecution timeMemory
587712Koosha_mvMeetings (IOI18_meetings)C++14
0 / 100
1 ms340 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define Add(x,y) x=(x+y)%mod #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first const int N=1e5+99,inf=1e9+99; int n,q,L[N],R[N]; ll res[N]; vector<int> H,A; vector<ll> ans; ll solve(vector<int> A){ vector<int> vec(1); f(i,0,A.size()) res[i]=0; f(i,1,A.size()-1){ res[i]=res[i-1]; while(A[i]>=vec.back()){ int x=vec.back(),y=x; vec.pop_back(); if(vec.size()) y=vec.back(); res[i]-=(x-y)*A[x]; } vec.pb(i); res[i]+=(i-vec.back())*A[i]; } f_(i,A.size()-2,1){ res[i]=res[i+1]; while(A[i]>=vec.back()){ int x=vec.back(),y=x; vec.pop_back(); if(vec.size()) y=vec.back(); res[i]-=(y-x)*A[x]; } vec.pb(i); res[i]+=(i-vec.back())*A[i]; } ll ans=N*inf; f(i,1,A.size()-1) minm(ans,res[i]); return ans; } vector<long long> minimum_costs(vector<int> _H,vector<int> L,vector<int> R){ q=L.size(),n=H.size(),H=_H; ans.resize(q); f(i,0,q){ A.clear(); A.pb(inf); f(j,L[i],R[i]+1) A.pb(H[j]); A.pb(inf); ans[i]=solve(A); } return ans; }

Compilation message (stderr)

meetings.cpp: In function 'long long int solve(std::vector<int>)':
meetings.cpp:9:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   33 |   f(i,0,A.size()) res[i]=0;
      |     ~~~~~~~~~~~~               
meetings.cpp:33:3: note: in expansion of macro 'f'
   33 |   f(i,0,A.size()) res[i]=0;
      |   ^
meetings.cpp:9:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   34 |   f(i,1,A.size()-1){
      |     ~~~~~~~~~~~~~~             
meetings.cpp:34:3: note: in expansion of macro 'f'
   34 |   f(i,1,A.size()-1){
      |   ^
meetings.cpp:56:11: warning: integer overflow in expression of type 'int' results in '502109225' [-Woverflow]
   56 |   ll ans=N*inf;
      |          ~^~~~
meetings.cpp:9:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   57 |   f(i,1,A.size()-1) minm(ans,res[i]);
      |     ~~~~~~~~~~~~~~             
meetings.cpp:57:3: note: in expansion of macro 'f'
   57 |   f(i,1,A.size()-1) minm(ans,res[i]);
      |   ^
#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...