답안 #755320

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
755320 2023-06-09T19:03:44 Z pera Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
327 ms 20820 KB
#include<bits/stdc++.h>
using namespace std;
 
#define int ll
#define ll long long
 
main(){
	int n , s;cin >> n >> s;
	vector<int> a , b;
	for(int i = 0;i < n;i ++){
	    int x;cin >> x;
	    if(i < n / 2) a.push_back(x);
	    else b.push_back(x);
	}
	vector<int> suma;
	for(int x = 0;x < (1LL << a.size());x ++){
	    int c = 0;
	    for(int i = 0;i < a.size();i ++){
	        if((1LL << i) & x) c += a[i]; 
	    }
	    suma.push_back(c);
	}
	sort(suma.begin() , suma.end());
	vector<int> sums;
	for(int x = 0;x < (1LL << b.size());x ++){
	    int c = 0;
	    for(int i = 0;i < b.size();i ++){
	        if((1LL << i) & x) c += b[i];
	    }
	    sums.push_back(c);
	}
	int ans = 0;
	sort(sums.begin() , sums.end());
	int y = sums.size() - 1 , p = sums.size() , oc = 0;
    for(int i = 0;i < suma.size();i ++){
        oc = 1;
        while(i + 1 < suma.size() && suma[i + 1] == suma[i]) ++ i , ++ oc;
        while(s - suma[i] < sums[y] && y >= 0) -- y , -- p;
        if(s - suma[i] >= sums[y]) ans += oc * p;
    }
	cout << ans << endl;
}

Compilation message

bobek.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      | ^~~~
bobek.cpp: In function 'int main()':
bobek.cpp:18:22: 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]
   18 |      for(int i = 0;i < a.size();i ++){
      |                    ~~^~~~~~~~~~
bobek.cpp:27:22: 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]
   27 |      for(int i = 0;i < b.size();i ++){
      |                    ~~^~~~~~~~~~
bobek.cpp:35:21: 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]
   35 |     for(int i = 0;i < suma.size();i ++){
      |                   ~~^~~~~~~~~~~~~
bobek.cpp:37:21: 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 |         while(i + 1 < suma.size() && suma[i + 1] == suma[i]) ++ i , ++ oc;
      |               ~~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 212 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 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 304 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 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 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 25 ms 1924 KB Output is correct
2 Correct 86 ms 5304 KB Output is correct
3 Correct 323 ms 20764 KB Output is correct
4 Correct 81 ms 5424 KB Output is correct
5 Correct 16 ms 1580 KB Output is correct
6 Correct 10 ms 944 KB Output is correct
7 Correct 20 ms 1592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 2752 KB Output is correct
2 Correct 26 ms 1900 KB Output is correct
3 Correct 122 ms 10464 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 6 ms 852 KB Output is correct
6 Correct 17 ms 1572 KB Output is correct
7 Correct 19 ms 1572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 3512 KB Output is correct
2 Correct 109 ms 6592 KB Output is correct
3 Correct 117 ms 6644 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 74 ms 6600 KB Output is correct
6 Correct 276 ms 20756 KB Output is correct
7 Correct 110 ms 6616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 231 ms 12792 KB Output is correct
2 Correct 28 ms 1864 KB Output is correct
3 Correct 10 ms 972 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 6 ms 852 KB Output is correct
6 Correct 221 ms 12652 KB Output is correct
7 Correct 16 ms 1484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1872 KB Output is correct
2 Correct 73 ms 5432 KB Output is correct
3 Correct 9 ms 852 KB Output is correct
4 Correct 8 ms 852 KB Output is correct
5 Correct 94 ms 6580 KB Output is correct
6 Correct 26 ms 2000 KB Output is correct
7 Correct 303 ms 20768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 308 ms 20792 KB Output is correct
2 Correct 27 ms 1892 KB Output is correct
3 Correct 8 ms 852 KB Output is correct
4 Correct 327 ms 20820 KB Output is correct
5 Correct 108 ms 10544 KB Output is correct
6 Correct 18 ms 1488 KB Output is correct
7 Correct 36 ms 2744 KB Output is correct