Submission #362380

# Submission time Handle Problem Language Result Execution time Memory
362380 2021-02-02T20:08:52 Z shahriarkhan Ice Hockey World Championship (CEOI15_bobek) C++14
50 / 100
401 ms 20944 KB
#include<bits/stdc++.h>
using namespace std ;

const int mx = 45 ;

int n , a[mx] , fs , ss ;

long long m , ans = 0 ;

vector<long long> vf , vs ;

int main()
{
    scanf("%d%lld",&n,&m) ;
    for(int i = 1 ; i <= n ; ++i)
    {
        scanf("%lld",&a[i]) ;
    }
    fs = n/2 , ss = n - fs ;
    for(int i = 0 ; i < (1<<fs) ; ++i)
    {
        long long sum = 0 ;
        for(int j = 0 ; j < fs ; ++j)
        {
            if(i&(1<<j)) sum += a[j+1] ;
        }
        vf.push_back(sum) ;
    }
    for(int i = 0 ; i < (1<<ss) ; ++i)
    {
        long long sum = 0 ;
        for(int j = 0 ; j < ss ; ++j)
        {
            if(i&(1<<j)) sum += a[j+fs+1] ;
        }
        vs.push_back(sum) ;
    }
    sort(vf.begin(),vf.end()) ;
    sort(vs.begin(),vs.end()) ;
    for(long long i : vf)
    {
        long long cnt = (upper_bound(vs.begin(),vs.end(),m-i) - vs.begin()) ;
        ans += cnt ;
    }
    printf("%lld\n",ans) ;
    return 0 ;
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:17:19: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
   17 |         scanf("%lld",&a[i]) ;
      |                ~~~^  ~~~~~
      |                   |  |
      |                   |  int*
      |                   long long int*
      |                %d
bobek.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%d%lld",&n,&m) ;
      |     ~~~~~^~~~~~~~~~~~~~~~
bobek.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |         scanf("%lld",&a[i]) ;
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2024 KB Output is correct
2 Correct 105 ms 5468 KB Output is correct
3 Correct 401 ms 20816 KB Output is correct
4 Correct 92 ms 5468 KB Output is correct
5 Correct 18 ms 1636 KB Output is correct
6 Correct 10 ms 1024 KB Output is correct
7 Correct 20 ms 1636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 2912 KB Output is correct
2 Correct 32 ms 2024 KB Output is correct
3 Correct 159 ms 10708 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 7 ms 1004 KB Output is correct
6 Correct 20 ms 1636 KB Output is correct
7 Correct 21 ms 1640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 3552 KB Output is correct
2 Correct 138 ms 6624 KB Output is correct
3 Correct 137 ms 6624 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 88 ms 6624 KB Output is correct
6 Correct 344 ms 20944 KB Output is correct
7 Correct 135 ms 6624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 268 ms 12760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 2024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 382 ms 20808 KB Output isn't correct
2 Halted 0 ms 0 KB -