제출 #971382

#제출 시각아이디문제언어결과실행 시간메모리
971382SunbaeIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
387 ms10684 KiB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 44;
vector<ll> v, a1, a2;
signed main(){
	int n; ll m; scanf("%d %lld", &n, &m);
	int k = n/2;
	for(int i = 0; i<k; ++i){
		ll x; scanf("%lld", &x); a1.push_back(x);
	}
	for(int i = k; i<n; ++i){
		ll x; scanf("%lld", &x); a2.push_back(x);
	}
	int sz1 = a1.size(), sz2 = a2.size();
	for(int mask = 0; mask < (1<<sz1); ++mask){
		ll sum = 0;
		for(int i = 0; i<sz1; ++i) if(mask>>i&1) sum += a1[i];
		v.push_back(sum);
	}
	sort(v.begin(), v.end());
	ll cnt = 0;
	for(int mask = 0; mask < (1<<sz2); ++mask){
		ll sum = 0;
		for(int i = 0; i<sz2; ++i) if(mask>>i&1) sum += a2[i];
		cnt += upper_bound(v.begin(), v.end(), m - sum) - v.begin();
	}
	printf("%lld", cnt);
}

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

bobek.cpp: In function 'int main()':
bobek.cpp:7:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  int n; ll m; scanf("%d %lld", &n, &m);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   ll x; scanf("%lld", &x); a1.push_back(x);
      |         ~~~~~^~~~~~~~~~~~
bobek.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   ll x; scanf("%lld", &x); a2.push_back(x);
      |         ~~~~~^~~~~~~~~~~~
#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...