Submission #398971

# Submission time Handle Problem Language Result Execution time Memory
398971 2021-05-04T23:32:44 Z Taresu Ice Hockey World Championship (CEOI15_bobek) C++11
100 / 100
572 ms 20844 KB
    #include <bits/stdc++.h>
     
    #define ll long long 
    #define pb push_back
    #define upb(a, x) upper_bound(a.begin(), a.end(), x)
    #define sz size 
    #define stvr(a) sort(a.begin(), a.end())
    using namespace std;
     
    vector<ll int> l, r, rr, l1, v;
    ll int  m;
    ll int n;
     
    bool lig(ll int a, ll int b){ return a&(1<<b); }
     
    int main(){
    	ios::sync_with_stdio(0);
    	cin >> n >> m;
     
    	for(ll int i=0;i<n;i++){
    		ll int a;
    	    cin >> a;
    		if(a<=m) v.pb(a);
    	}
     
    	for(ll int i=0;i<v.sz()/2;i++) l.pb(v[i]);
    	for(ll int i=v.sz()/2;i<v.sz();i++)r.pb(v[i]);
    	
    	for(ll int mask=0;mask<(1<<l.sz());mask++){
    		ll int a=0;
    		for(ll int i=0;i<l.sz();i++){
    			if(lig(mask, i)) a+=l[i];
    		}
    		if(a<=m) l1.pb(a);
    	}for(ll int mask=0;mask<(1<<r.sz());mask++){
    		ll int a=0;
    		for(ll int i=0;i<r.sz();i++){
    			if(lig(mask, i)) a+=r[i];
    		}
    		if(a<=m) rr.pb(a);
    	}
     
    	stvr(rr);
     
    	ll int resp=0;
    	for(ll int i=0;i<l1.size();i++){	
    		resp+=(ll int)(upb(rr, m-l1[i])-rr.begin());
    	}
     
    	cout << resp << '\n';
     
    	return 0;
    }

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:26: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]
   26 |      for(ll int i=0;i<v.sz()/2;i++) l.pb(v[i]);
      |                     ~^~~~~~~~~
bobek.cpp:27:29: 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(ll int i=v.sz()/2;i<v.sz();i++)r.pb(v[i]);
      |                            ~^~~~~~~
bobek.cpp:31:23: 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]
   31 |       for(ll int i=0;i<l.sz();i++){
      |                      ~^~~~~~~
bobek.cpp:37:23: 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 |       for(ll int i=0;i<r.sz();i++){
      |                      ~^~~~~~~
bobek.cpp:46: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]
   46 |      for(ll int i=0;i<l1.size();i++){
      |                     ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 248 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1944 KB Output is correct
2 Correct 104 ms 5544 KB Output is correct
3 Correct 572 ms 20752 KB Output is correct
4 Correct 103 ms 5444 KB Output is correct
5 Correct 15 ms 1612 KB Output is correct
6 Correct 8 ms 976 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 2804 KB Output is correct
2 Correct 33 ms 2000 KB Output is correct
3 Correct 199 ms 10508 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 8 ms 976 KB Output is correct
6 Correct 15 ms 1612 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 3512 KB Output is correct
2 Correct 147 ms 6556 KB Output is correct
3 Correct 151 ms 6588 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 83 ms 6636 KB Output is correct
6 Correct 263 ms 20816 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 355 ms 12808 KB Output is correct
2 Correct 31 ms 2000 KB Output is correct
3 Correct 11 ms 976 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 7 ms 976 KB Output is correct
6 Correct 223 ms 12724 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2020 KB Output is correct
2 Correct 102 ms 5400 KB Output is correct
3 Correct 11 ms 984 KB Output is correct
4 Correct 10 ms 988 KB Output is correct
5 Correct 91 ms 6576 KB Output is correct
6 Correct 25 ms 2008 KB Output is correct
7 Correct 1 ms 216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 403 ms 20844 KB Output is correct
2 Correct 33 ms 1968 KB Output is correct
3 Correct 11 ms 976 KB Output is correct
4 Correct 476 ms 20772 KB Output is correct
5 Correct 127 ms 10676 KB Output is correct
6 Correct 16 ms 1596 KB Output is correct
7 Correct 1 ms 204 KB Output is correct