Submission #335881

# Submission time Handle Problem Language Result Execution time Memory
335881 2020-12-14T07:50:29 Z beepbeepsheep Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
289 ms 25156 KB
#include <bits/stdc++.h>

using namespace std;
#define ll long long

const ll bignum=1e17;
const int inf= 2e9;
const int mod= 1e9+7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m,ele;
    cin>>n>>m;
    if (n==1){
        cin>>ele;
        cout<<(m>=ele?2:1);
        return 0;
    }
    vector<ll> a;
    vector<ll> b;
    vector<ll> a1;
    vector<ll> b1;
    vector<ll> temp;
    a1.push_back(0);
    b1.push_back(0);
    for (int i=0;i<n;i++){
        cin>>ele;
        if (i&1) a.push_back(ele);
        else b.push_back(ele);
    }
    for (int i=0;i<a.size();i++){
        temp.clear();
        for (int j=0;j<a1.size();j++){
            temp.push_back(a1[j]);
        }
        for (int k=0;k<temp.size();k++){
            a1.push_back(temp[k]+a[i]);
        }
    }
    for (int i=0;i<b.size();i++){
        temp.clear();
        for (int j=0;j<b1.size();j++){
            temp.push_back(b1[j]);
        }
        for (int k=0;k<temp.size();k++){
            b1.push_back(temp[k]+b[i]);
        }
    }
    sort(a1.begin(),a1.end());
    sort(b1.begin(),b1.end());
    ll ans=0;
    for (int i=0;i<a1.size();i++){
        ans+=upper_bound(b1.begin(),b1.end(),m-a1[i])-b1.begin();
    }
    cout<<ans;
    return 0;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int i=0;i<a.size();i++){
      |                  ~^~~~~~~~~
bobek.cpp:36:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for (int j=0;j<a1.size();j++){
      |                      ~^~~~~~~~~~
bobek.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for (int k=0;k<temp.size();k++){
      |                      ~^~~~~~~~~~~~
bobek.cpp:43:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (int i=0;i<b.size();i++){
      |                  ~^~~~~~~~~
bobek.cpp:45:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for (int j=0;j<b1.size();j++){
      |                      ~^~~~~~~~~~
bobek.cpp:48:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for (int k=0;k<temp.size();k++){
      |                      ~^~~~~~~~~~~~
bobek.cpp:55:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (int i=0;i<a1.size();i++){
      |                  ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 500 KB Output is correct
5 Correct 1 ms 512 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2528 KB Output is correct
2 Correct 65 ms 6484 KB Output is correct
3 Correct 289 ms 25028 KB Output is correct
4 Correct 64 ms 6484 KB Output is correct
5 Correct 9 ms 1892 KB Output is correct
6 Correct 8 ms 1128 KB Output is correct
7 Correct 14 ms 1892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 3420 KB Output is correct
2 Correct 22 ms 2652 KB Output is correct
3 Correct 106 ms 12620 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 4 ms 1128 KB Output is correct
6 Correct 13 ms 1892 KB Output is correct
7 Correct 14 ms 1892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 4568 KB Output is correct
2 Correct 96 ms 8656 KB Output is correct
3 Correct 97 ms 8780 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 46 ms 8656 KB Output is correct
6 Correct 213 ms 25024 KB Output is correct
7 Correct 92 ms 8656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 203 ms 16968 KB Output is correct
2 Correct 21 ms 2528 KB Output is correct
3 Correct 7 ms 1128 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 5 ms 1128 KB Output is correct
6 Correct 198 ms 17076 KB Output is correct
7 Correct 14 ms 1892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2676 KB Output is correct
2 Correct 64 ms 6484 KB Output is correct
3 Correct 7 ms 1128 KB Output is correct
4 Correct 7 ms 1128 KB Output is correct
5 Correct 55 ms 8656 KB Output is correct
6 Correct 20 ms 2656 KB Output is correct
7 Correct 285 ms 25028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 287 ms 25016 KB Output is correct
2 Correct 22 ms 2656 KB Output is correct
3 Correct 8 ms 1128 KB Output is correct
4 Correct 282 ms 25156 KB Output is correct
5 Correct 70 ms 12620 KB Output is correct
6 Correct 13 ms 1892 KB Output is correct
7 Correct 34 ms 3420 KB Output is correct