제출 #366180

#제출 시각아이디문제언어결과실행 시간메모리
366180dolphingarlic비스킷 담기 (IOI20_biscuits)C++14
42 / 100
1002 ms12524 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) { ll to_merge = ((a[i] - x) >> 1) << 1; if (to_merge) { if (i == a.size() - 1) a.push_back(to_merge >> 1); else a[i + 1] += (to_merge >> 1); } a[i] -= to_merge; } a.push_back(0); 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 >> 1)}] += cnt; if (dat.second >= x) { ans += cnt; if (dat.first != a.size() - 1) mp[{dat.first + 1, a[dat.first + 1] + (dat.second - x >> 1)}] += cnt; } } return ans; }

컴파일 시 표준 에러 (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:11:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |    if (i == a.size() - 1) a.push_back(to_merge >> 1);
      |        ~~^~~~~~~~~~~~~~~
biscuits.cpp:26:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   if (dat.first != a.size() - 1)
      |       ~~~~~~~~~~^~~~~~~~~~~~~~~
biscuits.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |    if (dat.first != a.size() - 1)
      |        ~~~~~~~~~~^~~~~~~~~~~~~~~
biscuits.cpp:31:55: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   31 |     mp[{dat.first + 1, a[dat.first + 1] + (dat.second - x >> 1)}] += 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...