Submission #124223

# Submission time Handle Problem Language Result Execution time Memory
124223 2019-07-02T19:16:06 Z kimbj0709 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
588 ms 20924 KB
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ull no_of_input,input,sum;
  ull total = 0;
  ull count = 0;
  vector<ull> vect1;
  vector<ull> vect2;
  vector<ull> vect3;
  vector<ull> vect4;
  cin >> no_of_input >> sum;

  for(int i=0;i<no_of_input;i++){
    cin >> input;
    if(i%2==0){
      vect1.push_back(input);
    }
    else{
      vect3.push_back(input);
    }
  }
  for(int i=0;i<pow(2,vect1.size());i++){

    for(int j=0;j<vect1.size();j++){
      if(i & (1<<j)){
          count += vect1[j];
       } 
    }
    vect2.push_back(count);
    count = 0;
  }
  for(int i=0;i<pow(2,vect3.size());i++){

    for(int j=0;j<vect3.size();j++){
      if(i & (1<<j)){
          count += vect3[j];
       } 
    }
    vect4.push_back(count);
    count = 0;
  }
  sort(vect2.begin(),vect2.end());
  sort(vect4.begin(),vect4.end());
  
  for(int i=0;i<vect2.size();i++){
    if(sum>=vect2[i]){
      total += upper_bound(vect4.begin(),vect4.end(),(sum-vect2[i]))-vect4.begin();
      //cout << total << "\n";
    }

    
    
  }
  cout << total;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:16:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<no_of_input;i++){
               ~^~~~~~~~~~~~
bobek.cpp:27:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0;j<vect1.size();j++){
                 ~^~~~~~~~~~~~~
bobek.cpp:37:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0;j<vect3.size();j++){
                 ~^~~~~~~~~~~~~
bobek.cpp:48:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<vect2.size();i++){
               ~^~~~~~~~~~~~~
# 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 256 KB Output is correct
4 Correct 2 ms 252 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 380 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 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 50 ms 2412 KB Output is correct
2 Correct 140 ms 5620 KB Output is correct
3 Correct 587 ms 20924 KB Output is correct
4 Correct 143 ms 5480 KB Output is correct
5 Correct 29 ms 1652 KB Output is correct
6 Correct 18 ms 1016 KB Output is correct
7 Correct 33 ms 1648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 2928 KB Output is correct
2 Correct 54 ms 2456 KB Output is correct
3 Correct 259 ms 10724 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 15 ms 1016 KB Output is correct
6 Correct 34 ms 1648 KB Output is correct
7 Correct 31 ms 1652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 4456 KB Output is correct
2 Correct 215 ms 8592 KB Output is correct
3 Correct 217 ms 8676 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 168 ms 8516 KB Output is correct
6 Correct 538 ms 20820 KB Output is correct
7 Correct 201 ms 8588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 458 ms 16944 KB Output is correct
2 Correct 51 ms 2416 KB Output is correct
3 Correct 18 ms 1016 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 16 ms 1012 KB Output is correct
6 Correct 444 ms 16724 KB Output is correct
7 Correct 31 ms 1652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2416 KB Output is correct
2 Correct 140 ms 5492 KB Output is correct
3 Correct 17 ms 988 KB Output is correct
4 Correct 17 ms 1016 KB Output is correct
5 Correct 172 ms 8600 KB Output is correct
6 Correct 52 ms 2416 KB Output is correct
7 Correct 528 ms 20856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 579 ms 20904 KB Output is correct
2 Correct 52 ms 2544 KB Output is correct
3 Correct 18 ms 1012 KB Output is correct
4 Correct 588 ms 20824 KB Output is correct
5 Correct 230 ms 10568 KB Output is correct
6 Correct 33 ms 1652 KB Output is correct
7 Correct 62 ms 2928 KB Output is correct