Submission #710622

#TimeUsernameProblemLanguageResultExecution timeMemory
710622groshiIce Hockey World Championship (CEOI15_bobek)C++17
100 / 100
443 ms8656 KiB
#include<bits/stdc++.h> #define int long long using namespace std; vector<int> Q; int t[2000000]; int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int n,m; cin>>n>>m; for(int i=0;i<n;i++) cin>>t[i]; for(int i=0;i<(1<<(n/2));i++) { int pom=i; int gdzie=0; int suma=0; while(pom>0) { if(pom%2==1) suma+=t[gdzie]; pom/=2; gdzie++; } Q.push_back(suma); } sort(Q.begin(),Q.end()); int wynik=0; for(int i=0;i<(1<<((n+1)/2));i++) { int pom=i; int gdzie=0; int suma=0; while(pom>0) { if(pom%2==1) suma+=t[gdzie+n/2]; pom/=2; gdzie++; } gdzie=upper_bound(Q.begin(),Q.end(),m-suma)-Q.begin(); gdzie--; if(gdzie>=0) wynik+=gdzie+1; } cout<<wynik; return 0; }
#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...