Submission #1005009

# Submission time Handle Problem Language Result Execution time Memory
1005009 2024-06-22T06:09:18 Z emad234 Ice Hockey World Championship (CEOI15_bobek) C++17
50 / 100
323 ms 10192 KB
#include "bits/stdc++.h"
#define F first
#define S second
#define ll long long
#define pii pair<ll,ll>
const int mxN = 2e5 + 5;
const int mod = 1e9 + 7;
using namespace std;
vector<ll>v;
ll a[50];
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    ll ans = 0;
    cin >>n>>m;
    for(int i = 0;i < n;i++) cin >>a[i];
    int hf = n / 2,sf = (n + 1) / 2;
    for(int mask = 0;mask < (1 << hf);mask++){
        ll sum = 0;
        for(int i = 0;i < hf;i++){
            if((mask >> i) % 2){
                sum += a[i];
                if(sum > m) break;
            }
        }
        if(sum > m) continue;
        v.push_back(sum);
    }
    // cout<<'\n';
    sort(v.begin(),v.end());
    // for(auto x : v) cout<<x<<' ';
    // cout<<'\n';
    for(int mask = 0;mask < (1 << sf);mask++){
        ll sum = 0;
        for(int i = 0;i < sf;i++){
            if((mask >> i) % 2){
                sum += a[i + hf];
                if(sum > m) break;
            }
        }
        if(sum > m) continue;
        ans += upper_bound(v.begin(),v.end(),m - sum) - v.begin();
        // cout<<sum<<' '<<upper_bound(v.begin(),v.end(),m - sum) - v.begin()<<'\n';
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 988 KB Output is correct
2 Correct 81 ms 2520 KB Output is correct
3 Correct 323 ms 9064 KB Output is correct
4 Correct 73 ms 2520 KB Output is correct
5 Correct 11 ms 992 KB Output is correct
6 Correct 5 ms 736 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1752 KB Output is correct
2 Correct 27 ms 992 KB Output is correct
3 Correct 148 ms 6212 KB Output is correct
4 Correct 0 ms 356 KB Output is correct
5 Correct 5 ms 736 KB Output is correct
6 Correct 13 ms 992 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 1608 KB Output is correct
2 Correct 132 ms 2520 KB Output is correct
3 Correct 110 ms 2516 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 62 ms 2544 KB Output is correct
6 Correct 186 ms 10192 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 113 ms 4820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 140 ms 9344 KB Output isn't correct
2 Halted 0 ms 0 KB -