제출 #730389

#제출 시각아이디문제언어결과실행 시간메모리
730389danikoynov비스킷 담기 (IOI20_biscuits)C++14
0 / 100
2 ms312 KiB
#include "biscuits.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll maxk = 63; ll n, dp[maxk], b[maxk]; long long count_tastiness(long long x, vector<long long> a) { a.resize(maxk); n = a.size(); b[0] = a[0]; for (int i = 1; i < maxk; i ++) { b[i] = b[i - 1] / 2 + a[i]; } dp[0] = 1; if (a[0] != 0) dp[0] ++; for (ll i = 1; i < maxk; i ++) { dp[i] = 0; if (b[i] < x) { ///cout << "here " << i << " " << b[i] << " " << x << endl; dp[i] = dp[i - 1]; continue; } dp[i] = dp[i - 1]; if (a[i] >= x) { dp[i] += dp[i - 1]; continue; } ll nec = (x - a[i]) * 2; for (int j = i - 1; j >= 0; j --) { ///cout << i << " : " << j << " : " << nec << " : " << a[j] << endl; if (a[j] >= nec + x) { dp[i] = dp[i] + dp[j]; break; } if (a[j] >= nec) { if (j == 0) dp[i] ++; else dp[i] = dp[i] + dp[j - 1]; nec = (x - (a[j] - nec)) * 2; } else { nec = (nec - a[j]) * 2; } } } //for (int j = 0; j < 5; j ++) // cout << dp[j] << " "; //cout << endl; return dp[maxk - 1]; }
#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...