Submission #124222

# Submission time Handle Problem Language Result Execution time Memory
124222 2019-07-02T19:15:17 Z kimbj0709 Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
615 ms 20972 KB
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
int main() {
  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:14:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<no_of_input;i++){
               ~^~~~~~~~~~~~
bobek.cpp:25:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0;j<vect1.size();j++){
                 ~^~~~~~~~~~~~~
bobek.cpp:35:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j=0;j<vect3.size();j++){
                 ~^~~~~~~~~~~~~
bobek.cpp:46: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 256 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 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 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 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 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 2304 KB Output is correct
2 Correct 144 ms 5448 KB Output is correct
3 Correct 615 ms 20924 KB Output is correct
4 Correct 147 ms 5476 KB Output is correct
5 Correct 28 ms 1648 KB Output is correct
6 Correct 17 ms 1012 KB Output is correct
7 Correct 31 ms 1644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 2924 KB Output is correct
2 Correct 53 ms 2412 KB Output is correct
3 Correct 254 ms 10572 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 15 ms 1016 KB Output is correct
6 Correct 33 ms 1636 KB Output is correct
7 Correct 31 ms 1648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 4436 KB Output is correct
2 Correct 218 ms 8668 KB Output is correct
3 Correct 219 ms 8532 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 176 ms 8540 KB Output is correct
6 Correct 541 ms 20924 KB Output is correct
7 Correct 194 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 450 ms 16848 KB Output is correct
2 Correct 52 ms 2412 KB Output is correct
3 Correct 18 ms 1016 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 15 ms 1012 KB Output is correct
6 Correct 442 ms 16848 KB Output is correct
7 Correct 32 ms 1648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 2408 KB Output is correct
2 Correct 141 ms 5476 KB Output is correct
3 Correct 18 ms 1012 KB Output is correct
4 Correct 18 ms 1016 KB Output is correct
5 Correct 175 ms 8540 KB Output is correct
6 Correct 51 ms 2608 KB Output is correct
7 Correct 526 ms 20972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 582 ms 20816 KB Output is correct
2 Correct 55 ms 2408 KB Output is correct
3 Correct 19 ms 1012 KB Output is correct
4 Correct 596 ms 20836 KB Output is correct
5 Correct 224 ms 10588 KB Output is correct
6 Correct 33 ms 1672 KB Output is correct
7 Correct 62 ms 2924 KB Output is correct