Submission #366177

#TimeUsernameProblemLanguageResultExecution timeMemory
366177dolphingarlicPacking Biscuits (IOI20_biscuits)C++14
0 / 100
1086 ms8684 KiB
#include "biscuits.h"

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll count_tastiness(ll x, vector<ll> a) {
	for (int i = 0; i < a.size(); i++) if (a[i] > x) {
		if (a[i] - x > 1) {
			if (i == a.size() - 1) a.push_back(a[i] - x >> 1);
			else a[i + 1] += (a[i] - x >> 1);
		}
		a[i] = x;
	}
	ll ans = 1;
	map<pair<int, ll>, ll> mp;
	mp[{0, a[0]}] = 1;
	while (mp.size()) {
		pair<int, ll> dat;
		ll cnt;
		tie(dat, cnt) = *mp.begin();
		mp.erase(mp.begin());
		if (dat.first != a.size() - 1)
			mp[{dat.first + 1, a[dat.first + 1] + (dat.second >> 1ll)}] += cnt;
		if (dat.second >= x) {
			ans += cnt;
			if (dat.first != a.size() - 1)
				mp[{dat.first + 1, a[dat.first + 1] + (dat.second - x >> 1ll)}] += cnt;
		}
	}
	return ans;
}

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:8:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (int i = 0; i < a.size(); i++) if (a[i] > x) {
      |                  ~~^~~~~~~~~~
biscuits.cpp:10:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |    if (i == a.size() - 1) a.push_back(a[i] - x >> 1);
      |        ~~^~~~~~~~~~~~~~~
biscuits.cpp:10:44: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   10 |    if (i == a.size() - 1) a.push_back(a[i] - x >> 1);
biscuits.cpp:11:27: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   11 |    else a[i + 1] += (a[i] - x >> 1);
biscuits.cpp:23:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   if (dat.first != a.size() - 1)
      |       ~~~~~~~~~~^~~~~~~~~~~~~~~
biscuits.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |    if (dat.first != a.size() - 1)
      |        ~~~~~~~~~~^~~~~~~~~~~~~~~
biscuits.cpp:28:55: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   28 |     mp[{dat.first + 1, a[dat.first + 1] + (dat.second - x >> 1ll)}] += cnt;
      |                                            ~~~~~~~~~~~^~~
#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...