Submission #867390

#TimeUsernameProblemLanguageResultExecution timeMemory
867390Muhammad_AneeqIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
363 ms16860 KiB
/* بسم الله الرحمن الرحيم Author: (:Muhammad Aneeq:) */ #pragma GCC optimize("O2") #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #include <iostream> #include <vector> #include <algorithm> using namespace std; #define int long long inline void solve() { int n,K; cin>>n>>K; int a[n]; for (auto& i:a) cin>>i; vector<int>x((1<<(n/2))),y(1<<(n-n/2)); for (int i=0;i<=x.size();++i) { int z=0; for (int j=0;j<n/2;j++) { if ((1<<j)&i) z+=a[j]; } x[i]=z; } for (int i=0;i<=y.size();i++) { int z=0; for (int j=0;j<n-n/2;j++) { if ((1<<j)&i) z+=a[n/2+j]; } y[i]=z; } sort(x.begin(), x.end()); int ans=0; for (auto i:y) { int z=upper_bound(x.begin(), x.end(),K-i)-begin(x); ans+=z; } cout<<ans<<endl; } signed main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); solve(); }

Compilation message (stderr)

bobek.cpp: In function 'void solve()':
bobek.cpp:22:17: 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]
   22 |   for (int i=0;i<=x.size();++i)
      |                ~^~~~~~~~~~
bobek.cpp:32:17: 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]
   32 |   for (int i=0;i<=y.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...