제출 #592824

#제출 시각아이디문제언어결과실행 시간메모리
592824andrei_boacaIce Hockey World Championship (CEOI15_bobek)C++14
100 / 100
306 ms20880 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n,v[45],m; vector<ll> v1,v2; vector<ll> s1,s2; int main() { cin>>n>>m; for(int i=1;i<=n;i++) { cin>>v[i]; if(i<=n/2) v1.push_back(v[i]); else v2.push_back(v[i]); } if(n==1) { ll ans=1; if(v[1]<=m) ans++; cout<<ans; return 0; } ll lg1=v1.size(); for(int mask=0;mask<(1<<lg1);mask++) { ll suma=0; for(int i=0;i<v1.size();i++) if((mask>>i)&1) suma+=v1[i]; if(suma<=m) s1.push_back(suma); } ll lg2=v2.size(); for(int mask=0;mask<(1<<lg2);mask++) { ll suma=0; for(int i=0;i<v2.size();i++) if((mask>>i)&1) suma+=v2[i]; if(suma<=m) s2.push_back(suma); } sort(s1.begin(),s1.end()); reverse(s1.begin(),s1.end()); sort(s2.begin(),s2.end()); ll poz=0; ll ans=0; for(ll a:s1) { while(poz<s2.size()&&s2[poz]+a<=m) poz++; poz--; ans+=poz+1; } cout<<ans; return 0; }

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

bobek.cpp: In function 'int main()':
bobek.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int i=0;i<v1.size();i++)
      |                     ~^~~~~~~~~~
bobek.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for(int i=0;i<v2.size();i++)
      |                     ~^~~~~~~~~~
bobek.cpp:54:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         while(poz<s2.size()&&s2[poz]+a<=m)
      |               ~~~^~~~~~~~~~
#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...
#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...