(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #818648

#TimeUsernameProblemLanguageResultExecution timeMemory
818648kevinsogoPacking Biscuits (IOI20_biscuits)C++17
100 / 100
40 ms51708 KiB
#include <bits/stdc++.h> using namespace std; #include "biscuits.h" using ll = long long; using lll = __int128; struct node { lll mn, mx, ad, sz; node *l, *r; }; using seq = node*; seq con(lll n, lll v) { return n == 0 ? nullptr : new node{v, v, 0, n, nullptr, nullptr}; } seq inc(seq s, lll a) { return a == 0 ? s : new node{s->mn, s->mx, s->ad + a, s->sz, s->l, s->r}; } seq conc(seq l, seq r, lll ad = 0) { if (l == nullptr) return inc(r, ad); if (r == nullptr) return inc(l, ad); assert(l->mx + l->ad <= r->mn + r->ad); return new node{l->mn + l->ad, r->mx + r->ad, ad, l->sz + r->sz, l, r}; } seq drop(seq s, lll u = 0) { u -= s->ad; return s->mx < u ? nullptr : u <= s->mn ? s : conc(drop(s->l, u), drop(s->r, u), s->ad); } lll size(seq s) { return s->sz; } ll count_tastiness(ll x, vector<ll> a) { a.resize(62); auto s = con(1, 0); for (int i = 0; i < a.size(); i++) s = drop(conc(inc(s, lll(-x) << i), s, lll(a[i]) << i)); return size(s); }

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int i = 0; i < a.size(); i++) s = drop(conc(inc(s, lll(-x) << i), s, lll(a[i]) << i));
      |                     ~~^~~~~~~~~~
#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...