Submission #304975

#TimeUsernameProblemLanguageResultExecution timeMemory
304975MarcoMeijerPacking Biscuits (IOI20_biscuits)C++14
0 / 100
2 ms640 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; // macros typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef pair<ll, ll> lll; typedef tuple<int, int, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<iii> viii; typedef vector<ll> vll; typedef vector<lll> vlll; #define REP(a,b,c) for(int a=int(b); a<int(c); a++) #define RE(a,c) REP(a,0,c) #define RE1(a,c) REP(a,1,c+1) #define REI(a,b,c) REP(a,b,c+1) #define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--) #define FOR(a,b) for(auto& a : b) #define all(a) a.begin(), a.end() #define INF 1e9 #define EPS 1e-9 #define pb push_back #define popb pop_back #define fi first #define se second #define sz size() const ll MX=10, MX2=10; ll x; vll a; ll dp[MX][MX2]; void addDP(ll i, ll j, ll v) { if(j < 0) return; j /= 2; if(j >= MX2) j = MX2; dp[i][j] += v; } ll getDP(ll i, ll j) { if(j < 0) j = 0; if(j >= MX2) return 0; return dp[i][j]; } ll count_tastiness(ll X, vll A) { x=X; a=A; while(a.size() < MX) a.pb(0); RE(i,MX) { if(a[i] >= x+2) { ll rem = ((a[i]-x)/2ll)*2ll; a[i ] -= rem; a[i+1] += rem/2ll; } } // base cases /*RE(i,MX) dp[i].clear(); dp[0][a[0]] += 1; if(a[0]-x >= 0) dp[0][a[0]-x] += 1; REP(i,1,MX) { FOR(p,dp[i-1]) { addDP(i, (p.fi+2ll*a[i])/2ll, p.se); addDP(i, (p.fi+2ll*a[i]-2ll*x)/2ll, p.se); } } ll ans = 0; FOR(p,dp[MX-1]) ans += p.se;*/ RE(i,MX) RE(j,MX2) dp[i][j] = 0; dp[0][a[0]] += 1; if(a[0]-x >= 0) dp[0][a[0]-x] += 1; RE(i,MX-1) RE(j,MX2) { if(!dp[i][j]) continue; addDP(i+1, (j+2ll*a[i+1] ), dp[i][j]); addDP(i+1, (j+2ll*a[i+1]-2ll*x), dp[i][j]); } RE(j,MX) REV(i,1,MX2) dp[j][i-1] += dp[j][i]; return dp[MX-1][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...