Submission #431393

#TimeUsernameProblemLanguageResultExecution timeMemory
431393Andyvanh1Packing Biscuits (IOI20_biscuits)C++14
12 / 100
2 ms332 KiB
#include <bits/stdc++.h> #include "biscuits.h" using namespace std; #define vt vector #define pb push_back #define all(x) (x).begin(),(x).end() #define rep(i,x) for(int (i) = 0; (i) < (x); (i)++) typedef long long ll; typedef long double ld; typedef vt<int> vi; typedef pair<int,int> pii; vt<ll> A; ll X; int k; bool works(ll cur){ ll now = 0; ll lat = 0; for(int i = 0; i < 60; i++){ if(i<k) now+=A[i]*(1ll<<i); lat+=((1ll<<i)&cur)*X; if(now<lat)return false; } return true; } ll brute_force(ll x, vt<ll> a){ if(x>100000)return 1; X = x; A = a;k =a.size(); ll ans = 0; for(ll i = 100000; i >= 0; i--){ if(works(i))ans++; } return ans; } ll count_tastiness(ll x, vt<ll> a){ int k = a.size(); vt<vt<ll>> dp(k+1, vt<ll>(k+1)); vt<ll> uno(k); uno[0] = a[0]; for(int i = 1; i < k; i++){ uno[i] = a[i] + uno[i-1]/2; } rep(i,k+1){ if(i>uno[k-1])dp[k][i] = 0; else dp[k][i] = uno[k-1]-i+1; } for(int i = k-1; i > 0; i--){ for(int j = 0; j < i; j++){ ll x = uno[i-1]-j; if(x>0) dp[i][j] = dp[i+1][uno[i]-a[i]-x/2]+dp[i+1][uno[i]-a[i]-(x-1)/2]; else dp[i][j] = dp[i+1][uno[i]-a[i]-x/2]; } } return dp[1][0]; }

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:10:26: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   10 | #define rep(i,x) for(int (i) = 0; (i) < (x); (i)++)
      |                          ^
biscuits.cpp:57:1: note: in expansion of macro 'rep'
   57 | rep(i,k+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...