답안 #259464

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
259464 2020-08-07T21:41:05 Z MatheusLealV Ice Hockey World Championship (CEOI15_bobek) C++17
100 / 100
721 ms 25148 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long int 
 
vector<ll> masks[2]; //eu vou ordenar o segundo bloco, e pra cada cara no 1o eu faço uma BB no 2o
ll resp = 0, m, arr[40];
int n, maxmask;

int mask_roll(int l, int r, bool div){

	//calcular a mascara base
	maxmask = (1LL << (r - l + 1));

	for(int i = 0; i < maxmask; i++){

		ll soma = 0, roll = i;

		for(int j = l; j <= r; j++){

			if(roll%2) soma += arr[j];
			roll >>= 1;
		}

		masks[div].push_back(soma);
	}
}

ll bb(ll num){

	//return +1
	ll val = - 1;

	int ini = 0, fim = maxmask-1;

	while(ini <= fim){

		int mid = (ini+fim)/2;

		if(masks[1][mid] + num <= m){
			val = mid;
			ini = mid+1;
		}
		else 
			fim = mid-1;
	}

	return val+1;	
}

int main(){

	cin >> n >> m;

	for(int i = 0; i < n; i++)
		cin >> arr[i];

	int mid = n/2;

	mask_roll(0, mid, 0);
	mask_roll(mid+1, n-1, 1);

	sort(masks[1].begin(), masks[1].end());

	for(int i = 0; i < (int)masks[0].size(); i++){
		resp += bb(masks[0][i]);
	}

	cout << resp << endl;

	return 0;
}

Compilation message

bobek.cpp: In function 'int mask_roll(int, int, bool)':
bobek.cpp:27:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 2420 KB Output is correct
2 Correct 141 ms 6492 KB Output is correct
3 Correct 721 ms 25120 KB Output is correct
4 Correct 149 ms 6492 KB Output is correct
5 Correct 18 ms 1908 KB Output is correct
6 Correct 8 ms 1144 KB Output is correct
7 Correct 17 ms 1908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 3512 KB Output is correct
2 Correct 35 ms 2420 KB Output is correct
3 Correct 285 ms 12688 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 8 ms 1144 KB Output is correct
6 Correct 17 ms 1908 KB Output is correct
7 Correct 17 ms 1908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 4456 KB Output is correct
2 Correct 174 ms 8544 KB Output is correct
3 Correct 180 ms 8716 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 90 ms 8544 KB Output is correct
6 Correct 333 ms 24892 KB Output is correct
7 Correct 105 ms 8668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 379 ms 16848 KB Output is correct
2 Correct 34 ms 2420 KB Output is correct
3 Correct 14 ms 1144 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 10 ms 1144 KB Output is correct
6 Correct 199 ms 16724 KB Output is correct
7 Correct 17 ms 1908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 2420 KB Output is correct
2 Correct 140 ms 6620 KB Output is correct
3 Correct 13 ms 1144 KB Output is correct
4 Correct 13 ms 1156 KB Output is correct
5 Correct 100 ms 8544 KB Output is correct
6 Correct 22 ms 2420 KB Output is correct
7 Correct 318 ms 24892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 547 ms 25148 KB Output is correct
2 Correct 37 ms 2420 KB Output is correct
3 Correct 14 ms 1144 KB Output is correct
4 Correct 706 ms 24960 KB Output is correct
5 Correct 162 ms 12624 KB Output is correct
6 Correct 18 ms 1908 KB Output is correct
7 Correct 35 ms 3432 KB Output is correct