답안 #102014

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
102014 2019-03-21T13:49:58 Z Nicholas_Patrick Bali Sculptures (APIO15_sculpture) C++17
0 / 100
3 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

int n, a, b;
vector <long long> y, psy;
vector <int> memo;
int depth;
int checkPossibility(long long x, long long toDeduct=0, int checkFrom=0){
	if(checkFrom==n)
		return 0;
	if(memo[checkFrom])
		return memo[checkFrom];
	int ret=n;
	int curres;
	for(int i = checkFrom;i < n;i ++){
		if(((psy[i]-toDeduct)|x)==x)
			depth++;
			curres=checkPossibility(x, psy[i], i+1);
			depth--;
			if(curres+depth>=a)
				ret=min(ret, curres);
		if(psy[i]-toDeduct>x)
			break;
	}
	return memo[checkFrom]=ret+1;
}
int main(){
	scanf("%d %d %d", &n, &a, &b);
	y.resize(n);
	psy.resize(n);
	for(int i = 0;i < n;i ++)
		scanf("%lld", &y[i]);
	psy[0]=y[0];
	for(int i = 1;i < n;i ++)
		psy[i]=psy[i-1]+y[i];
	if(a==1){
		long long check=0x1FFFFFFFFFF;
		for(int i = 40;i >= 0;i --){
			memo.clear();
			memo.resize(n, 0);
			if(checkPossibility(check-(1ll<<i))<=b)
				check-=1ll<<i;
		}
		printf("%lld\n", check);
	}else{
		long long check=0x1FFFFFFFFFF;
		for(int i = 40;i >= 0;i --){
			memo.clear();
			memo.resize(n, 0);
			depth=0;
			if(checkPossibility(check-(1ll<<i))<=b)
				check-=1ll<<i;
		}
		printf("%lld\n", check);
	}
}

Compilation message

sculpture.cpp: In function 'int checkPossibility(long long int, long long int, int)':
sculpture.cpp:16:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if(((psy[i]-toDeduct)|x)==x)
   ^~
sculpture.cpp:18:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    curres=checkPossibility(x, psy[i], i+1);
    ^~~~~~
sculpture.cpp: In function 'int main()':
sculpture.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &a, &b);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &y[i]);
   ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 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 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 -