제출 #560517

#제출 시각아이디문제언어결과실행 시간메모리
560517AlperenT비스킷 담기 (IOI20_biscuits)C++17
컴파일 에러
0 ms0 KiB
// #include "biscuits.h" #include <bits/stdc++.h> using namespace std; long long count_tastiness(long long x, vector<long long> arr){ vector<pair<long long, long long>> prv, cur; while(!arr.empty() && arr.back() == 0) arr.pop_back(); cur.push_back({0, 1}); int k = 0; while(true){ bool flag = false; long long cnt = k < arr.size() ? arr[k] : 0; for(auto i : cur) if(i.first / 2 + cnt - x >= 0) flag = true; if(flag || k < arr.size()){ prv.clear(); sort(cur.begin(), cur.end()); for(auto p : cur){ if(prv.empty() || (prv.back().first != p.first / 2)) prv.push_back({p.first / 2, p.second}); else prv.back().second += p.second; } cur.clear(); for(auto i : prv){ cur.push_back({i.first + cnt, i.second}); if(i.first + cnt - x >= 0) cur.push_back({i.first + cnt - x, i.second}); } } else break; k++; } long long ans = 0; for(auto p : cur) ans += p.second; return ans; } int main(){ long long t, x, n; cin >> t; while(t--){ cin >> n >> x; vector<long long> v(n); for(auto &i : v) cin >> i; cout << count_tastiness(x, v) << "\n"; } }

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

biscuits.cpp: In function 'long long int count_tastiness(long long int, std::vector<long long int>)':
biscuits.cpp:17:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   long long cnt = k < arr.size() ? arr[k] : 0;
      |                   ~~^~~~~~~~~~~~
biscuits.cpp:21:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   if(flag || k < arr.size()){
      |              ~~^~~~~~~~~~~~
/usr/bin/ld: /tmp/ccYWWoRn.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cczuEa1o.o:biscuits.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status