제출 #828010

#제출 시각아이디문제언어결과실행 시간메모리
828010minhcool비스킷 담기 (IOI20_biscuits)C++17
42 / 100
63 ms19576 KiB
//#define local #ifndef local #include "biscuits.h" #endif #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #define int long long #define fi first #define se second #define pb push_back #define mp make_pair typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; const int N = 3e5 + 5; const int oo = 1e18 + 7, mod = 1e9 + 7; mt19937 rng(1); int rnd(int l, int r){ int temp = rng() % (r - l + 1); return abs(temp) + l; } int dp[125][20005], expected[121]; long long count_tastiness(long long x, std::vector<long long> a) { //int n, a[N]; int sum = 0; for(int i = 0; i < a.size(); i++) sum += a[i] * (1LL << i); if(sum <= 1e5){ int answer = 1; for(int i = 1; i <= sum/x; i++){ int rem = 0; for(int j = 0; j < a.size(); j++){ rem += a[j]; if((i & (1LL << j))) rem -= x; if(rem < 0) break; rem /= 2; } //if(rem >= 0) cout << answer << "\n"; answer += (rem >= 0); } return answer; } else if(x <= 1e4){ //cout << "OK\n"; for(int i = 0; i <= 20000; i++){ for(int j = 0; j <= 122; j++) dp[j][i] = 0; } expected[0] = a[0]; for(int i = 1; i < a.size() + 62; i++) expected[i] = (expected[i - 1] / 2) + (i < a.size() ? a[i] : 0); dp[0][0] = 1; if(a[0] >= x) dp[0][x] = 1; for(int i = 0; (i + 1) < a.size() + 62; i++){ for(int j = 0; j <= 20000; j++){ //if(dp[i][j]) cout << i << " " << j << " " << dp[i][j] << "\n"; int nxt = ((expected[i] - j) / 2) + ((i + 1) < a.size() ? a[i + 1] : 0), actual = expected[i + 1] - nxt; dp[i + 1][actual] += dp[i][j]; if(nxt >= x){ nxt -= x, actual += x; dp[i + 1][actual] += dp[i][j]; } } } int answer = 0; for(int j = 0; j <= 20000; j++) answer += dp[a.size() + 61][j]; return answer; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:36:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for(int i = 0; i < a.size(); i++) sum += a[i] * (1LL << i);
      |                 ~~^~~~~~~~~~
biscuits.cpp:41:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |    for(int j = 0; j < a.size(); j++){
      |                   ~~^~~~~~~~~~
biscuits.cpp:58:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   for(int i = 1; i < a.size() + 62; i++) expected[i] = (expected[i - 1] / 2) + (i < a.size() ? a[i] : 0);
      |                  ~~^~~~~~~~~~~~~~~
biscuits.cpp:58:83: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |   for(int i = 1; i < a.size() + 62; i++) expected[i] = (expected[i - 1] / 2) + (i < a.size() ? a[i] : 0);
      |                                                                                 ~~^~~~~~~~~~
biscuits.cpp:61:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |   for(int i = 0; (i + 1) < a.size() + 62; i++){
      |                  ~~~~~~~~^~~~~~~~~~~~~~~
biscuits.cpp:64:50: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     int nxt = ((expected[i] - j) / 2) + ((i + 1) < a.size() ? a[i + 1] : 0), actual = expected[i + 1] - nxt;
      |                                          ~~~~~~~~^~~~~~~~~~
#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...