(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 #538407

#TimeUsernameProblemLanguageResultExecution timeMemory
538407EqualTurtlePacking Biscuits (IOI20_biscuits)C++14
100 / 100
47 ms1236 KiB
#include "biscuits.h" #include<bits/stdc++.h> using namespace std; constexpr long long MAXK = 63; long long dp[MAXK]; long long sum[MAXK]; long long sx[MAXK]; long long logg(long long n){ int curr = -1; while (n > 0){ n = (n >> 1); curr++; } return curr; } long long foo(long long n) { if (n <= 0) return 0; if (n == 1) return 1; long long l = logg(n); if (n == (1LL << l)) l--; long long res = dp[l] + foo(min(n, 1 + sx[l]) - (1LL << l)); return res; } long long count_tastiness(long long x, vector<long long> a) { sum[0] = 0; for (long long i = 0; i < MAXK - 1; i++) { if (i < (long long)a.size()) sum[i] += a[i] * (1LL << i); sx[i] = sum[i] / x; sum[i + 1] = sum[i]; } for (long long i = 0; i < MAXK-1; i++) dp[i] = foo(1LL << i); //for (int i = 0; i < 4; i++) // cout << sum[i] << " " << sx[i] << " " << dp[i] << "\n"; return dp[MAXK - 2]; }
#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...