Submission #638800

# Submission time Handle Problem Language Result Execution time Memory
638800 2022-09-07T14:00:20 Z hadksjhiqu Ice Hockey World Championship (CEOI15_bobek) C++14
60 / 100
1000 ms 74280 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
    ll n,m;
    cin>>n>>m;
    vector<ll> v(n);
    for(auto &i:v) cin>>i;
    map<ll,int> frq;
    for(int mask=0;mask<(1<<n/2);mask++){
        ll sum = 0;
        for(int i=0;i<(n>>1);i++){
            if((1<<i)&mask){
                sum += v[i];
            }
        }
        frq[sum] ++;
    }
    int prev = 0;
    vector<ll> tmp;
    for(auto &i : frq){
        i.second += prev;
        tmp.push_back(i.first);
        prev = i.second;
    }
    int rem = n-(n>>1);
    ll ans = 0;
    for(int mask=0;mask<(1<<rem);mask++){
        ll sum = 0;
        for(int i=0;i<rem;i++){
            if((1<<i)&mask){
                sum += v[(n>>1)+i];
            }
        }
        if(sum > m) continue;
        int upper = upper_bound(tmp.begin(),tmp.end(),m-sum) - tmp.begin();
        upper --;
        if (frq.find(tmp[upper]) != frq.end()) ans += frq[tmp[upper]];
    }
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 1236 KB Output is correct
2 Correct 334 ms 13016 KB Output is correct
3 Execution timed out 1088 ms 33288 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 1868 KB Output is correct
2 Correct 74 ms 4052 KB Output is correct
3 Correct 238 ms 1144 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 7 ms 340 KB Output is correct
6 Correct 21 ms 2404 KB Output is correct
7 Correct 27 ms 4928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 176 ms 8132 KB Output is correct
2 Correct 525 ms 9204 KB Output is correct
3 Correct 380 ms 9232 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 70 ms 224 KB Output is correct
6 Correct 302 ms 1864 KB Output is correct
7 Correct 180 ms 18896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 37364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 86 ms 4960 KB Output is correct
2 Correct 368 ms 18876 KB Output is correct
3 Correct 19 ms 2644 KB Output is correct
4 Correct 28 ms 2632 KB Output is correct
5 Correct 83 ms 212 KB Output is correct
6 Correct 37 ms 5032 KB Output is correct
7 Execution timed out 1020 ms 74280 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 74256 KB Time limit exceeded
2 Halted 0 ms 0 KB -