Submission #1121534

#TimeUsernameProblemLanguageResultExecution timeMemory
1121534vjudge1Ice Hockey World Championship (CEOI15_bobek)C++17
40 / 100
1086 ms20900 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ld double const int INF = 1e18; const int mod = 12345; const int sz = 3e5 + 5; const int usz = 1e6 + 5; signed main() { ios_base::sync_with_stdio(0);cin.tie(0); int n , m; cin >> n >> m; vector < int > a(n); for(int i = 0;i < n;i++) cin >> a[i]; sort(a.begin() , a.end()); vector < int > q1; vector < int > q2; for(int i = 0;i < n / 2 + (n & 1);i++) q1.push_back(a[i]); for(int i = n / 2 + (n & 1);i < n;i++) q2.push_back(a[i]); vector < int > pos1; vector < int > pos2; for(int bit = 0;bit <= pow(2 , q1.size()) - 1;bit++) { int sum = 0; for(int i = 0;i < q1.size();i++) { if((1 << i) & bit) { sum += q1[i]; } } if(sum <= m) pos1.push_back(sum); } for(int bit = 0;bit <= pow(2 , q2.size()) - 1;bit++) { int sum = 0; for(int i = 0;i < q2.size();i++) { if((1 << i) & bit) { sum += q2[i]; } } if(sum <= m) pos2.push_back(sum); } sort(pos1.begin() , pos1.end()); sort(pos2.begin() , pos2.end()); int ans = 0; for(int i = 0;i < pos1.size();i++) { for(int j = 0;j < pos2.size();j++) { if(pos1[i] + pos2[j] <= m) ans++; } } cout << ans << endl; }

Compilation message (stderr)

bobek.cpp: In function 'int main()':
bobek.cpp:30: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]
   30 |      for(int i = 0;i < q1.size();i++)
      |                    ~~^~~~~~~~~~~
bobek.cpp:42: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]
   42 |      for(int i = 0;i < q2.size();i++)
      |                    ~~^~~~~~~~~~~
bobek.cpp:54:20: 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]
   54 |    for(int i = 0;i < pos1.size();i++)
      |                  ~~^~~~~~~~~~~~~
bobek.cpp:56: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]
   56 |      for(int j = 0;j < pos2.size();j++)
      |                    ~~^~~~~~~~~~~~~
#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...