Submission #93343

# Submission time Handle Problem Language Result Execution time Memory
93343 2019-01-07T16:18:32 Z RezwanArefin01 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
354 ms 20844 KB
///usr/bin/g++ -O2 $0 -o ${0%.cpp} && echo "----------" && ./${0%.cpp}; exit;
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii; 

const int N = 50; 
int n; ll X; 
vector<ll> a, b; 

void gen(int i, vector<ll> &a, vector<ll> &A, ll S = 0) {
    if(S > X) return; 
    if(i == a.size()) { A.push_back(S); return; }
    gen(i + 1, a, A, S + a[i]); 
    gen(i + 1, a, A, S); 
}

int main() {
    scanf("%d %lld", &n, &X);
    vector<ll> a, b; 
    for(int i = 0; i < n; i++) {
        ll x; scanf("%lld", &x); 
        if(i < n / 2) a.push_back(x); 
        else b.push_back(x); 
    }
    vector<ll> A, B; 
    gen(0, a, A); 
    gen(0, b, B); 
    sort(A.begin(), A.end()); 
    
    ll ans = 0; 
    for(ll Y : B) ans += lower_bound(A.begin(), A.end(), X - Y + 1) - A.begin(); 
    printf("%lld\n", ans); 
}

Compilation message

bobek.cpp: In function 'void gen(int, std::vector<long long int>&, std::vector<long long int>&, ll)':
bobek.cpp:14:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(i == a.size()) { A.push_back(S); return; }
        ~~^~~~~~~~~~~
bobek.cpp: In function 'int main()':
bobek.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %lld", &n, &X);
     ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:23:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         ll x; scanf("%lld", &x); 
               ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 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 256 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 23 ms 2032 KB Output is correct
2 Correct 83 ms 5480 KB Output is correct
3 Correct 334 ms 20844 KB Output is correct
4 Correct 76 ms 5476 KB Output is correct
5 Correct 12 ms 1648 KB Output is correct
6 Correct 6 ms 1016 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 2920 KB Output is correct
2 Correct 23 ms 2028 KB Output is correct
3 Correct 159 ms 10588 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 5 ms 1012 KB Output is correct
6 Correct 10 ms 1652 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 3560 KB Output is correct
2 Correct 132 ms 6624 KB Output is correct
3 Correct 136 ms 6624 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 39 ms 6624 KB Output is correct
6 Correct 142 ms 20836 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 257 ms 12756 KB Output is correct
2 Correct 22 ms 2032 KB Output is correct
3 Correct 8 ms 1012 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 5 ms 1144 KB Output is correct
6 Correct 107 ms 12756 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2032 KB Output is correct
2 Correct 77 ms 5476 KB Output is correct
3 Correct 7 ms 1012 KB Output is correct
4 Correct 7 ms 1012 KB Output is correct
5 Correct 67 ms 6624 KB Output is correct
6 Correct 12 ms 2032 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 317 ms 20792 KB Output is correct
2 Correct 25 ms 2032 KB Output is correct
3 Correct 8 ms 1012 KB Output is correct
4 Correct 354 ms 20816 KB Output is correct
5 Correct 67 ms 10592 KB Output is correct
6 Correct 10 ms 1644 KB Output is correct
7 Correct 2 ms 256 KB Output is correct