답안 #208175

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
208175 2020-03-10T07:14:24 Z fr_klr Ice Hockey World Championship (CEOI15_bobek) C++14
0 / 100
6 ms 632 KB
//I wanna live before i die
#include<bits/stdc++.h>
using namespace std;

const long long maxn = 500 + 5, inf = 1e16 + 69, V = 5, delta = 998244353;
int n, m;
map<int, int> w;
vector<pair<int, int> > part;
vector<int> v;
int dp[maxn];
int find_first(int mask){
    for(int i = 0;; i++)
        if((1 << i) & mask)
            return i;
}

void first_part(int sz){
    for(int mask = 1; mask < (1 << sz); mask++){
        int u = find_first(mask);
        if(__builtin_popcount(mask) == 1)
            dp[mask] = v[u];
        else
            dp[mask] = dp[mask - (mask & -mask)] + v[u];
        w[dp[mask]]++;
    }
}

int make_part_1(){
    part.push_back(make_pair(0, 1));
    int A = 1;
    for(auto e : w){
        int f = e.first;
        int s = part[part.size() - 1].second + e.second;
        part.push_back(make_pair(f, s));
        A = s;
    }
    return A;
}
int find_amount(int A){
    if(A < 0)
        return 0;
    pair<int, int> p = {A, inf};
    int e = upper_bound(part.begin(), part.end(), p) - part.begin();
    return part[e - 1].second;
}
int second_part(int sz){
    memset(dp, 0, sizeof dp);
    long long Ans = 0;
    for(int mask = 1; mask < (1 << (n - sz)); mask++){
        int u = find_first(mask) + sz;
        if(__builtin_popcount(mask) == 1)
            dp[mask] = v[u];
        else
            dp[mask] = dp[mask - (mask & -mask)] + v[u];

        Ans += find_amount(m - dp[mask] - 1);
    }
    return Ans;
}
void input(){
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
}
void calc(){
    first_part(n / 2);
    cout << (make_part_1() + second_part(n / 2)) << endl;
}
int main(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    input();
    calc();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 508 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 552 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -