답안 #120593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
120593 2019-06-25T05:04:34 Z Mercenary Ice Hockey World Championship (CEOI15_bobek) C++14
20 / 100
315 ms 16804 KB
#include<bits/stdc++.h>

using namespace std;
#define taskname "A"
#define pb	push_back
#define mp 	make_pair
#ifndef LOCAL
#define cerr if(0)cout
#endif

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,int> lli;
const int maxn = 1e6 + 6;
const ld inf = 1e9 + 5;

int n;
ll a[maxn];
ll can;
vector<ll> val , val1;
void enter(){
    cin >> n >> can;
    for(int i = 0 ; i < n / 2 ; ++i){
        cin >> a[i];
    }
    val.reserve((1 << (n / 2)));
    for(int j = 0 ; j < (1 << (n / 2)) ; ++j){
        ll sum = 0;
        for(int i = 0 ; i < n / 2 ; ++i){
            if((j >> i) & 1)sum += a[i];
        }
        val.pb(sum);
    }
    sort(val.begin(),val.end());
    n -= (n / 2);
    for(int i = 0 ; i < n ; ++i){
        cin >> a[i];
    }
    val1.reserve((1 << n));
    for(int j = 0 ; j < (1 << n) ; ++j){
        ll sum = 0;
        for(int i = 0 ; i < n ; ++i){
            if((j >> i) & 1)sum += a[i];
        }
        val1.pb(sum);
    }
    sort(val1.begin(),val1.end());
    int j = val.size() - 1;
    int res = 0;
    for(int c : val1){
        while(j >= 0 && val[j] + c > can)--j;
        res += j + 1;
//        cout << j << endl;
    }
    cout << res;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    enter();
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:63:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".INP", "r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
bobek.cpp:64:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".OUT", "w",stdout);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 1920 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 2444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 57 ms 3472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 229 ms 12792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 1920 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 315 ms 16804 KB Output isn't correct
2 Halted 0 ms 0 KB -