Submission #415571

#TimeUsernameProblemLanguageResultExecution timeMemory
415571Theo830Packing Biscuits (IOI20_biscuits)C++17
0 / 100
1096 ms332 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll INF = 1e9+7; ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ll,ii> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Deltix Round, Spring 2021 (open for everyone, rated, Div. 1 + Div. 2) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<ll> distr; ll rnd(ll a, ll b){return distr(rng)%(b-a+1)+a;} #include "biscuits.h" /* long long count_tastiness(long long x, std::vector<long long> a); int main() { int q; assert(scanf("%d", &q) == 1); vector<int> k(q); vector<long long> x(q); vector<vector<long long>> a(q); vector<long long> results(q); for (int t = 0; t < q; t++) { assert(scanf("%d%lld", &k[t], &x[t]) == 2); a[t] = vector<long long>(k[t]); for (int i = 0; i < k[t]; i++) { assert(scanf("%lld", &a[t][i]) == 1); } } fclose(stdin); for (int t = 0; t < q; t++) { results[t] = count_tastiness(x[t], a[t]); } for (int t = 0; t < q; t++) { printf("%lld\n", results[t]); } fclose(stdout); return 0; } */ ll A[150] = {0}; ll k; ll omades; ll solve(ll idx,ll posa){ if(idx == 150){ return 1;// + (posa / omades); } ll em = posa + A[idx]; ll ans = solve(idx+1,em / 2); if(em >= omades){ em -= omades; ans += solve(idx+1,em / 2); } return ans; } long long count_tastiness(long long x, vector<long long> a){ k = a.size(); memset(A,0,sizeof A); f(i,0,a.size()){ A[i] += a[i]; if(A[i] > x){ ll ex = A[i] - x; A[i] = x; A[i+1] += ex / 2; } } omades = x; return solve(0,0); } /* 2 3 3 5 2 1 3 2 2 1 2 */

Compilation message (stderr)

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:8:33: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 | #define f(i,a,b) for(ll i = a;i < b;i++)
......
   75 |     f(i,0,a.size()){
      |       ~~~~~~~~~~~~               
biscuits.cpp:75:5: note: in expansion of macro 'f'
   75 |     f(i,0,a.size()){
      |     ^
#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...