Submission #335881

#TimeUsernameProblemLanguageResultExecution timeMemory
335881beepbeepsheepIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
289 ms25156 KiB
#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 (stderr)

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 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...