답안 #118658

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
118658 2019-06-19T10:35:31 Z roseanne_pcy Ice Hockey World Championship (CEOI15_bobek) C++14
50 / 100
507 ms 8680 KB
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

int n;
ll S;

const int maxn = 45;
int arr[maxn];

vector< ll > half;

ll ways;

int main()
{
	scanf("%d %lld", &n, &S);
	for(int i = 1; i<= n; i++) scanf("%d", &arr[i]);
	int m = n/2;
	for(int bit = 0; bit< (1<<m); bit++)
	{
		ll loc = 0;
		for(int i = 0; i< m; i++)
		{
			if((1<<i) & bit) loc += arr[i+1];
		}
		half.pb(loc);
	}
	sort(half.begin(), half.end());
	m = n-n/2;
	for(int bit = 0; bit< (1<<m); bit++)
	{
		ll loc = 0;
		for(int i = 0; i< m; i++)
		{
			if((1<<i)&bit) loc += arr[n/2+1+i];
		}
		ways += upper_bound(half.begin(), half.end(), S-loc)-half.begin();
	}
	printf("%lld\n", ways);
}

Compilation message

bobek.cpp: In function 'int main()':
bobek.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %lld", &n, &S);
  ~~~~~^~~~~~~~~~~~~~~~~~~
bobek.cpp:24:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i<= n; i++) scanf("%d", &arr[i]);
                             ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 1020 KB Output is correct
2 Correct 107 ms 2548 KB Output is correct
3 Correct 507 ms 8668 KB Output is correct
4 Correct 109 ms 2548 KB Output is correct
5 Correct 17 ms 1020 KB Output is correct
6 Correct 9 ms 768 KB Output is correct
7 Correct 16 ms 1020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 1528 KB Output is correct
2 Correct 35 ms 1020 KB Output is correct
3 Correct 207 ms 4628 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 8 ms 768 KB Output is correct
6 Correct 17 ms 1020 KB Output is correct
7 Correct 16 ms 1020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 1528 KB Output is correct
2 Correct 169 ms 2552 KB Output is correct
3 Correct 160 ms 2548 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 85 ms 2548 KB Output is correct
6 Correct 257 ms 8632 KB Output is correct
7 Correct 83 ms 2548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 187 ms 4580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 1020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 278 ms 8680 KB Output isn't correct
2 Halted 0 ms 0 KB -