Submission #40515

# Submission time Handle Problem Language Result Execution time Memory
40515 2018-02-03T14:50:45 Z Pajaraja Ice Hockey World Championship (CEOI15_bobek) C++14
50 / 100
583 ms 8892 KB
#include <bits/stdc++.h>
using namespace std;
long long a[40],c[2000000];
long long binarna(int l,int r,long long val)
{
	if(l==r) return l;
	int s=(l+r)/2;
	if(c[s]>val) return binarna(l,s,val);
	return binarna(s+1,r,val);
}
int main()
{
	int n;
	long long m,sol=0;
	scanf("%d%lld",&n,&m);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	int p=n/2;
	for(int i=0;i<(1<<p);i++)
	{
		int ma=i;
		long long pr=0;
		for(int j=0;j<p;j++)
		{
			if(ma%2==0) pr+=a[j];
			ma/=2;
		}
		c[i]=pr;
	}
	c[1<<p]=1000000000000000000LL;
	sort(c,c+(1<<p)+1);
	int q=n-p;
	for(int i=0;i<(1<<q);i++)
	{
		int ma=i;
		long long pr=0;
		for(int j=0;j<q;j++)
		{
			if(ma%2==0) pr+=a[p+j];
			ma/=2;
		}
		sol+=binarna(0,(1<<p),m-pr);
	}
	printf("%lld",sol);
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:16:39: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  for(int i=0;i<n;i++) scanf("%d",&a[i]);
                                       ^
bobek.cpp:15:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%lld",&n,&m);
                       ^
bobek.cpp:16:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<n;i++) scanf("%d",&a[i]);
                                        ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Output is correct
2 Correct 1 ms 388 KB Output is correct
3 Correct 2 ms 404 KB Output is correct
4 Correct 1 ms 404 KB Output is correct
5 Correct 2 ms 464 KB Output is correct
6 Correct 2 ms 532 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 38 ms 1004 KB Output is correct
2 Correct 129 ms 2660 KB Output is correct
3 Correct 583 ms 8820 KB Output is correct
4 Correct 123 ms 8820 KB Output is correct
5 Correct 19 ms 8820 KB Output is correct
6 Correct 10 ms 8820 KB Output is correct
7 Correct 18 ms 8820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 8820 KB Output is correct
2 Correct 42 ms 8820 KB Output is correct
3 Correct 259 ms 8820 KB Output is correct
4 Correct 2 ms 8820 KB Output is correct
5 Correct 11 ms 8820 KB Output is correct
6 Correct 20 ms 8820 KB Output is correct
7 Correct 21 ms 8820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 90 ms 8820 KB Output is correct
2 Correct 221 ms 8820 KB Output is correct
3 Correct 197 ms 8820 KB Output is correct
4 Correct 2 ms 8820 KB Output is correct
5 Correct 107 ms 8820 KB Output is correct
6 Correct 316 ms 8820 KB Output is correct
7 Correct 100 ms 8820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 238 ms 8820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 8820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 345 ms 8892 KB Output isn't correct
2 Halted 0 ms 0 KB -