Submission #755320

#TimeUsernameProblemLanguageResultExecution timeMemory
755320peraIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
327 ms20820 KiB
#include<bits/stdc++.h> using namespace std; #define int ll #define ll long long main(){ int n , s;cin >> n >> s; vector<int> a , b; for(int i = 0;i < n;i ++){ int x;cin >> x; if(i < n / 2) a.push_back(x); else b.push_back(x); } vector<int> suma; for(int x = 0;x < (1LL << a.size());x ++){ int c = 0; for(int i = 0;i < a.size();i ++){ if((1LL << i) & x) c += a[i]; } suma.push_back(c); } sort(suma.begin() , suma.end()); vector<int> sums; for(int x = 0;x < (1LL << b.size());x ++){ int c = 0; for(int i = 0;i < b.size();i ++){ if((1LL << i) & x) c += b[i]; } sums.push_back(c); } int ans = 0; sort(sums.begin() , sums.end()); int y = sums.size() - 1 , p = sums.size() , oc = 0; for(int i = 0;i < suma.size();i ++){ oc = 1; while(i + 1 < suma.size() && suma[i + 1] == suma[i]) ++ i , ++ oc; while(s - suma[i] < sums[y] && y >= 0) -- y , -- p; if(s - suma[i] >= sums[y]) ans += oc * p; } cout << ans << endl; }

Compilation message (stderr)

bobek.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      | ^~~~
bobek.cpp: In function 'int main()':
bobek.cpp:18:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |      for(int i = 0;i < a.size();i ++){
      |                    ~~^~~~~~~~~~
bobek.cpp:27:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |      for(int i = 0;i < b.size();i ++){
      |                    ~~^~~~~~~~~~
bobek.cpp:35:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i = 0;i < suma.size();i ++){
      |                   ~~^~~~~~~~~~~~~
bobek.cpp:37:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         while(i + 1 < suma.size() && suma[i + 1] == suma[i]) ++ i , ++ oc;
      |               ~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...