답안 #393877

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
393877 2021-04-24T18:31:15 Z Pietra Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
571 ms 20832 KB
#include<bits/stdc++.h>
using namespace std ; 
#define int long long 
 
const int maxn = 40 ; 
 
int x, n, v[maxn], ans ; 
vector<int> m1, m2 ; 
 
int32_t main(){
 
	cin >> n >> x ; 
 
	for(int i = 0 ; i < n ; i++) cin >> v[i] ; 
 
	int esq = (n+1)>>1 ; 
    int dir = (n>>1) ; 
 
	for(int mask = 0 ; mask < (1<<dir) ; mask++){
		int s = 0 ; 
		for(int i = 0 ; i < dir ; i++){
			if(mask&(1<<i)) s += v[i] ; 
		}
		m1.push_back(s) ; 
	}
 
	for(int mask = 0 ; mask < (1<<esq) ; mask++){
		int s = 0 ;
		for(int i = 0 ; i < esq ; i++){
			if(mask&(1<<i)) s += v[i+dir] ; 
		} 
		m2.push_back(s) ; 
	}
 
	sort(m2.begin(), m2.end()) ; 
 
	for(int i = 0 ; i < m1.size() ; i++){
		int u = upper_bound(m2.begin(), m2.end(), x - m1[i]) - m2.begin() ; 
		ans += u ; 
	}
 
	cout << ans << "\n" ; 
 
} 

Compilation message

bobek.cpp: In function 'int32_t main()':
bobek.cpp:37:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for(int i = 0 ; i < m1.size() ; i++){
      |                  ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 1992 KB Output is correct
2 Correct 104 ms 5428 KB Output is correct
3 Correct 571 ms 20776 KB Output is correct
4 Correct 106 ms 5424 KB Output is correct
5 Correct 15 ms 1604 KB Output is correct
6 Correct 8 ms 936 KB Output is correct
7 Correct 15 ms 1476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 2752 KB Output is correct
2 Correct 33 ms 1992 KB Output is correct
3 Correct 199 ms 10456 KB Output is correct
4 Correct 1 ms 216 KB Output is correct
5 Correct 7 ms 844 KB Output is correct
6 Correct 15 ms 1476 KB Output is correct
7 Correct 16 ms 1476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 3472 KB Output is correct
2 Correct 156 ms 6620 KB Output is correct
3 Correct 154 ms 6584 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 83 ms 6464 KB Output is correct
6 Correct 266 ms 20764 KB Output is correct
7 Correct 114 ms 6496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 351 ms 12692 KB Output is correct
2 Correct 31 ms 1916 KB Output is correct
3 Correct 11 ms 960 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 9 ms 844 KB Output is correct
6 Correct 223 ms 12724 KB Output is correct
7 Correct 16 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 1992 KB Output is correct
2 Correct 102 ms 5436 KB Output is correct
3 Correct 11 ms 968 KB Output is correct
4 Correct 10 ms 844 KB Output is correct
5 Correct 95 ms 6584 KB Output is correct
6 Correct 25 ms 1936 KB Output is correct
7 Correct 296 ms 20784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 408 ms 20832 KB Output is correct
2 Correct 36 ms 1944 KB Output is correct
3 Correct 11 ms 964 KB Output is correct
4 Correct 564 ms 20748 KB Output is correct
5 Correct 125 ms 10500 KB Output is correct
6 Correct 15 ms 1480 KB Output is correct
7 Correct 32 ms 2880 KB Output is correct