답안 #208179

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
208179 2020-03-10T07:18:42 Z fr_klr Ice Hockey World Championship (CEOI15_bobek) C++14
0 / 100
1000 ms 90820 KB
//I wanna live before i die
#include<bits/stdc++.h>
using namespace std;
 
const long long maxn = (1 << 20) + 20, inf = 1e19 + 69, V = 5, delta = 998244353;
long long n, m;
map<long long, long long> w;
vector<pair<long long, long long> > part;
vector<long long> v;
long long dp[maxn];
long long find_first(long long mask){
    for(long long i = 0;; i++)
        if((1 << i) & mask)
            return i;
}
 
void first_part(long long sz){
    for(long long mask = 1; mask < (1 << sz); mask++){
        long long 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]]++;
    }
}
 
long long make_part_1(){
    part.push_back(make_pair(0, 1));
    long long A = 1;
    for(auto e : w){
        long long f = e.first;
        long long s = part[part.size() - 1].second + e.second;
        part.push_back(make_pair(f, s));
        A = s;
    }
    return A;
}
long long find_amount(long long A){
    if(A < 0)
        return 0;
    pair<long long, long long> p = {A, inf};
    long long e = upper_bound(part.begin(), part.end(), p) - part.begin();
    return part[e - 1].second;
}
long long second_part(long long sz){
    memset(dp, 0, sizeof dp);
    long long Ans = 0;
    for(long long mask = 1; mask < (1 << (n - sz)); mask++){
        long long 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(long long i = 0; i < n; i++){
        long long 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();
}

Compilation message

bobek.cpp:5:51: warning: overflow in implicit constant conversion [-Woverflow]
 const long long maxn = (1 << 20) + 20, inf = 1e19 + 69, V = 5, delta = 998244353;
                                              ~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 8568 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 8616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 8568 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 8568 KB Output is correct
2 Incorrect 11 ms 8568 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 34 ms 9648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 10224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 106 ms 16996 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 868 ms 49780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 13896 KB Output is correct
2 Correct 274 ms 29152 KB Output is correct
3 Correct 24 ms 11248 KB Output is correct
4 Incorrect 31 ms 11252 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1089 ms 90820 KB Time limit exceeded
2 Halted 0 ms 0 KB -