Submission #59788

#TimeUsernameProblemLanguageResultExecution timeMemory
59788WA_TLEHoliday (IOI14_holiday)C++14
24 / 100
55 ms2220 KiB
#include<deque> #include<queue> #include<vector> #include<algorithm> #include<iostream> #include<set> #include<cmath> #include<tuple> #include<string> //#include<chrono> #include<functional> #include<iterator> #include<random> #include<unordered_set> #include<array> #include<map> #include<iomanip> #include<assert.h> #include<bitset> #include<stack> using namespace std; typedef long long int llint; typedef long double lldo; #define mp make_pair #define mt make_tuple #define pub push_back #define puf push_front #define pob pop_back #define pof pop_front #define fir first #define sec second #define res resize #define ins insert #define era erase /* cout<<setprecision(20) cin.tie(0); ios::sync_with_stdio(false); */ const llint mod=1e9+7; const llint big=2.19e15+1; const long double pai=3.141592653589793238462643383279502884197; const long double eps=1e-15; template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}} template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}} llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);} //llint lcm(llint a,llint b){return a/gcd(a,b)*b;} template<class T> void SO(T& ve){sort(ve.begin(),ve.end());} template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());} template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();} template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();} /* ioi2014 day2 hoilday 拡張 convex full trick 凸関数とそうでない関数のマージを行う */ #include"holiday.h" vector<llint>pot;//spot,point vector<llint>solve(int sta,int owa){ //solveのstaからowaまでのマージを行う //愚直~ vector<llint>ans((owa-sta)*2); vector<llint>gen; int i,j; for(i=0;i<owa-sta;i++){ llint t=pot[i+sta]; int bas=gen.size(); gen.pub(t); while(0<bas&&gen[bas-1]<gen[bas]){ swap(gen[bas-1],gen[bas]); bas--; } llint now=0; for(j=0;j<gen.size();j++){ now+=gen[j]; maxeq(ans[i+j+1],now); } } //for(auto it:ans){cout<<it<<" ";}cout<<endl; return ans; } llint findMaxAttraction(int n,int start,int d,int attraction[]){ //初めに左に行く場合と右に行く場合を計算 if(3000<n){return 0;} llint ans=0; pot.resize(n+n); llint i; for(i=0;i<=start;i++){pot[i]=attraction[start-i];} vector<llint>hahi=solve(0,start+1); for(i=0;i<n+n;i++){pot[i]=0;} for(i=1;i<n-start;i++){pot[2*i]=attraction[i+start];} vector<llint>mdmg=solve(0,(n-start)*2); for(i=0;i<n+n;i++){pot[i]=0;} for(i=0;i<=d;i++){ llint ge=hahi[min((llint)hahi.size()-1,i)]+mdmg[min((llint)mdmg.size()-1,d-i)]; maxeq(ans,ge); } for(i=0;i<=start;i++){pot[2*i]=attraction[start-i];} vector<llint>mdhi=solve(0,(start+1)*2); for(i=0;i<n+n;i++){pot[i]=0;} for(i=1;i<n-start;i++){pot[i]=attraction[i+start];} vector<llint>hamg=solve(0,(n-start)); for(i=0;i<n+n;i++){pot[i]=0;} for(i=0;i<=d;i++){ llint ge=mdhi[min((llint)mdhi.size()-1,i)]+hamg[min((llint)hamg.size()-1,d-i)]; maxeq(ans,ge); } return ans; }

Compilation message (stderr)

holiday.cpp: In function 'std::vector<long long int> solve(int, int)':
holiday.cpp:74:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0;j<gen.size();j++){
           ~^~~~~~~~~~~
grader.cpp: In function 'int main()':
grader.cpp:7:12: warning: variable 'n_s' set but not used [-Wunused-but-set-variable]
     int i, n_s;
            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...