Submission #124600

# Submission time Handle Problem Language Result Execution time Memory
124600 2019-07-03T14:50:59 Z Kamisama Ice Hockey World Championship (CEOI15_bobek) C++14
100 / 100
510 ms 21048 KB
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <chrono>
#include <vector>
#include <algorithm>
#define GetBit(x,k) ((x)>>(k)&1)
#define taskname "TEST"
using namespace std;

int n;
long long m,a[41],res;
vector<long long> sumL,sumR;

inline void Attempt(const int &low, const int &high, vector<long long> &v){
    for(int state=0;state<1<<(high-low+1);state++){
        long long sum=0;
        for(int i=low;i<=high;i++) sum+=a[i]*(GetBit(state,i-low));
        v.push_back(sum);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); if(fopen(taskname".INP","r"))
    freopen(taskname".INP","r",stdin),
    freopen(taskname".OUT","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    Attempt(1,n/2,sumL); Attempt(n/2+1,n,sumR);
    sort(sumR.begin(),sumR.end());
    for(auto x: sumL) res+=upper_bound(sumR.begin(),sumR.end(),m-x)-sumR.begin();
    cout<<res;
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:26:38: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen(taskname".INP","r",stdin),
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
     freopen(taskname".OUT","w",stdout);
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bobek.cpp:26:38: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 324 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2040 KB Output is correct
2 Correct 102 ms 5480 KB Output is correct
3 Correct 506 ms 21032 KB Output is correct
4 Correct 100 ms 5484 KB Output is correct
5 Correct 14 ms 1656 KB Output is correct
6 Correct 7 ms 1016 KB Output is correct
7 Correct 13 ms 1652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 2928 KB Output is correct
2 Correct 31 ms 2036 KB Output is correct
3 Correct 202 ms 10592 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 6 ms 1016 KB Output is correct
6 Correct 13 ms 1652 KB Output is correct
7 Correct 13 ms 1652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 3564 KB Output is correct
2 Correct 148 ms 6668 KB Output is correct
3 Correct 145 ms 6628 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 63 ms 6632 KB Output is correct
6 Correct 221 ms 21048 KB Output is correct
7 Correct 93 ms 6676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 309 ms 12760 KB Output is correct
2 Correct 28 ms 2036 KB Output is correct
3 Correct 10 ms 1016 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 7 ms 1016 KB Output is correct
6 Correct 192 ms 12872 KB Output is correct
7 Correct 13 ms 1652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2036 KB Output is correct
2 Correct 98 ms 5480 KB Output is correct
3 Correct 10 ms 1016 KB Output is correct
4 Correct 10 ms 1012 KB Output is correct
5 Correct 89 ms 6628 KB Output is correct
6 Correct 22 ms 2160 KB Output is correct
7 Correct 213 ms 20820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 377 ms 20824 KB Output is correct
2 Correct 33 ms 2032 KB Output is correct
3 Correct 10 ms 1016 KB Output is correct
4 Correct 510 ms 20824 KB Output is correct
5 Correct 99 ms 10596 KB Output is correct
6 Correct 14 ms 1652 KB Output is correct
7 Correct 24 ms 2924 KB Output is correct