Submission #867388

# Submission time Handle Problem Language Result Execution time Memory
867388 2023-10-28T10:10:25 Z Faisal_Saqib Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
408 ms 22456 KB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define int long long
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int ans=0;
    int fn=(n/2);
    vector<int> fh,sh;
    for(int mask=0;mask<(1ll<<fn);mask++)
    {
        int sum=0;
        for(int j=0;j<fn;j++)
            if(mask&(1ll<<j))
                sum+=a[j];
        if(sum<=m)
            fh.push_back(sum);
    }
    sort(begin(fh),end(fh));
    int sn=n-fn;
    for(int mask=0;mask<(1ll<<sn);mask++)
    {
        int sum=0;
        for(int j=0;j<sn;j++)
            if(mask&(1ll<<j))
                sum+=a[j+fn];
        if(sum<=m)
            sh.push_back(sum);
    }
    for(auto i:sh)
        ans+=upper_bound(begin(fh),end(fh),(m-i))-begin(fh);
    cout<<ans<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 456 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 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 1 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 1 ms 500 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 Correct 28 ms 2140 KB Output is correct
2 Correct 90 ms 5464 KB Output is correct
3 Correct 390 ms 21336 KB Output is correct
4 Correct 88 ms 5576 KB Output is correct
5 Correct 12 ms 1500 KB Output is correct
6 Correct 7 ms 1116 KB Output is correct
7 Correct 8 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 3020 KB Output is correct
2 Correct 32 ms 2144 KB Output is correct
3 Correct 179 ms 10792 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 6 ms 1116 KB Output is correct
6 Correct 13 ms 1756 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 3552 KB Output is correct
2 Correct 149 ms 8320 KB Output is correct
3 Correct 135 ms 8176 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 74 ms 6608 KB Output is correct
6 Correct 228 ms 21192 KB Output is correct
7 Correct 49 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 290 ms 14396 KB Output is correct
2 Correct 27 ms 2140 KB Output is correct
3 Correct 9 ms 1116 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 6 ms 1116 KB Output is correct
6 Correct 173 ms 13380 KB Output is correct
7 Correct 8 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 2016 KB Output is correct
2 Correct 85 ms 5368 KB Output is correct
3 Correct 8 ms 1112 KB Output is correct
4 Correct 9 ms 992 KB Output is correct
5 Correct 83 ms 7500 KB Output is correct
6 Correct 22 ms 2396 KB Output is correct
7 Correct 135 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 363 ms 22456 KB Output is correct
2 Correct 30 ms 2144 KB Output is correct
3 Correct 11 ms 1116 KB Output is correct
4 Correct 408 ms 21072 KB Output is correct
5 Correct 112 ms 12476 KB Output is correct
6 Correct 13 ms 1500 KB Output is correct
7 Correct 16 ms 348 KB Output is correct