답안 #742526

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742526 2023-05-16T11:38:19 Z MODDI Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
297 ms 20808 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n;
ll m;
bool check_bit(int n, int bit){
	int ok = n & (1 << bit);
	if(ok)	return true;
	return false;
}
int main(){
	cin>>n>>m;
	vl arr(n+1);
	for(int i =1; i <= n; i++)	cin>>arr[i];
	vl msk1, msk2;
	int k = n / 2;
	for(int i = 0; i < (1 << k); i++){
		ll sum = 0;
		for(int j = 0; j < k; j++){
			if(check_bit(i, j))
				sum += arr[j+1];
		}
		msk1.pb(sum);
	}
	for(int i = 0; i < (1 << n - k); i++){
		ll sum = 0;
		for(int j = 0; j < n-k; j++){
			if(check_bit(i, j))
				sum += arr[j+k+1];
		}
		msk2.pb(sum);
	}
	sort(msk1.begin(), msk1.end());
	sort(msk2.begin(), msk2.end());
	int j = 0;
	ll ans = 0;
	for(int i = msk1.size()-1; i >= 0; i--){
		while(j < msk2.size() && msk2[j] + msk1[i] <= m)	j++;
		ans += j;
	}
	cout<<ans<<endl;
	return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:31:29: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   31 |  for(int i = 0; i < (1 << n - k); i++){
      |                           ~~^~~
bobek.cpp:44:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   while(j < msk2.size() && msk2[j] + msk1[i] <= m) j++;
      |         ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 2008 KB Output is correct
2 Correct 67 ms 5424 KB Output is correct
3 Correct 297 ms 20796 KB Output is correct
4 Correct 80 ms 5376 KB Output is correct
5 Correct 12 ms 1572 KB Output is correct
6 Correct 9 ms 852 KB Output is correct
7 Correct 18 ms 1484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 2820 KB Output is correct
2 Correct 24 ms 1988 KB Output is correct
3 Correct 117 ms 10560 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 6 ms 940 KB Output is correct
6 Correct 15 ms 1484 KB Output is correct
7 Correct 15 ms 1484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 3508 KB Output is correct
2 Correct 102 ms 6500 KB Output is correct
3 Correct 101 ms 6544 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 65 ms 6500 KB Output is correct
6 Correct 243 ms 20728 KB Output is correct
7 Correct 105 ms 6588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 215 ms 12684 KB Output is correct
2 Correct 25 ms 1984 KB Output is correct
3 Correct 10 ms 852 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 6 ms 852 KB Output is correct
6 Correct 220 ms 12684 KB Output is correct
7 Correct 16 ms 1484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1968 KB Output is correct
2 Correct 68 ms 5312 KB Output is correct
3 Correct 8 ms 964 KB Output is correct
4 Correct 8 ms 964 KB Output is correct
5 Correct 75 ms 6592 KB Output is correct
6 Correct 28 ms 1872 KB Output is correct
7 Correct 285 ms 20764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 281 ms 20732 KB Output is correct
2 Correct 26 ms 1996 KB Output is correct
3 Correct 9 ms 968 KB Output is correct
4 Correct 294 ms 20808 KB Output is correct
5 Correct 94 ms 10544 KB Output is correct
6 Correct 15 ms 1484 KB Output is correct
7 Correct 32 ms 2888 KB Output is correct