답안 #971382

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
971382 2024-04-28T12:35:13 Z Sunbae Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
387 ms 10684 KB
#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);
}

Compilation message

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);
      |         ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 984 KB Output is correct
2 Correct 85 ms 2512 KB Output is correct
3 Correct 380 ms 10684 KB Output is correct
4 Correct 83 ms 2512 KB Output is correct
5 Correct 14 ms 984 KB Output is correct
6 Correct 7 ms 728 KB Output is correct
7 Correct 13 ms 1072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 1492 KB Output is correct
2 Correct 28 ms 984 KB Output is correct
3 Correct 169 ms 5716 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 6 ms 728 KB Output is correct
6 Correct 14 ms 1240 KB Output is correct
7 Correct 13 ms 984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 1492 KB Output is correct
2 Correct 135 ms 2512 KB Output is correct
3 Correct 128 ms 2508 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 81 ms 2512 KB Output is correct
6 Correct 231 ms 9664 KB Output is correct
7 Correct 74 ms 2512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 297 ms 5324 KB Output is correct
2 Correct 25 ms 980 KB Output is correct
3 Correct 9 ms 724 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 7 ms 728 KB Output is correct
6 Correct 159 ms 4556 KB Output is correct
7 Correct 13 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 984 KB Output is correct
2 Correct 80 ms 2508 KB Output is correct
3 Correct 8 ms 728 KB Output is correct
4 Correct 8 ms 728 KB Output is correct
5 Correct 100 ms 2512 KB Output is correct
6 Correct 20 ms 1240 KB Output is correct
7 Correct 224 ms 10172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 328 ms 10324 KB Output is correct
2 Correct 30 ms 984 KB Output is correct
3 Correct 8 ms 724 KB Output is correct
4 Correct 387 ms 10440 KB Output is correct
5 Correct 118 ms 5400 KB Output is correct
6 Correct 14 ms 984 KB Output is correct
7 Correct 26 ms 1488 KB Output is correct