제출 #955595

#제출 시각아이디문제언어결과실행 시간메모리
955595Trisanu_Das비스킷 담기 (IOI20_biscuits)C++17
77 / 100
204 ms1420 KiB
#include"biscuits.h" #ifndef EVAL #include"grader.cpp" #endif #include<bits/stdc++.h> using namespace std; typedef long long ll; ll x; map<ll,ll>dp[61]; vector<ll>a; ll rec(int pos,int cur){ if(pos==61)return 1ll; if(dp[pos].count(cur))return dp[pos][cur]; auto it=dp[pos].lower_bound(cur); if(true){ auto itt=it; if(itt!=dp[pos].begin()){ itt--; if(itt->second==it->second)return it->second; } } dp[pos][cur]=rec(pos+1,(cur+a[pos])>>1); if(a[pos]+cur>=x)dp[pos][cur]+=rec(pos+1,(a[pos]+cur-x)>>1); return dp[pos][cur]; } ll count_tastiness(ll X,vector<ll>A){ a=A;x=X; a.resize(61); for(int i=0;i<61;i++)dp[i].clear(); for(int i=0;i<60;i++) if(a[i]>x){ ll tmp=(a[i]-x)>>1ll; a[i+1]+=tmp; a[i]-=(tmp<<1ll); } return rec(0,0); }
#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...