답안 #137983

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137983 2019-07-28T17:30:03 Z sebinkim Bitwise (BOI06_bitwise) C++14
25 / 100
2 ms 380 KB
#include <bits/stdc++.h>

using namespace std;

int S[111], L[111], R[111];
int n, k, s;

bool check(int t)
{
	int i, j, l, f;
	
	for(i=1, j=1; i<=k; i++){
		for(l=j; l<=S[i]; l++){
			if(L[l] & R[l] & t){
				L[l] -= t; R[l] -= t;
				break;
			}
		}
		if(l <= S[i]){
			j = S[i] + 1;
			continue;
		}
		
		for(f=0; j<=S[i]; j++){
			if(R[j] & t){
				if(f) R[j] = t - 1;
				else{
					L[j] = 0; R[j] -= t;
					f = 1;
				}
			}
		}
		
		if(!f) return 0;
		j = S[i] + 1;
	}
	
	return 1;
}

int main()
{
	int i;
	
	scanf("%d%d", &n, &k);
	
	for(i=1; i<=k; i++){
		scanf("%d", S + i);
		S[i] += S[i - 1];
	}
	
	for(i=1; i<=n; i++){
		scanf("%d%d", L + i, R + i);
	}
	
	for(i=30; i>=0; i--){
		if(check(1 << i)){
			s |= 1 << i;
		}
	}
	
	printf("%d\n", s);
	
	return 0;
}

Compilation message

bitwise.cpp: In function 'int main()':
bitwise.cpp:45:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~
bitwise.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", S + i);
   ~~~~~^~~~~~~~~~~~~
bitwise.cpp:53:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", L + i, R + i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 252 KB Output isn't correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Incorrect 2 ms 252 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 2 ms 256 KB Output isn't correct
8 Incorrect 2 ms 256 KB Output isn't correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Correct 2 ms 376 KB Output is correct
11 Incorrect 2 ms 376 KB Output isn't correct
12 Incorrect 2 ms 256 KB Output isn't correct
13 Incorrect 2 ms 256 KB Output isn't correct
14 Incorrect 2 ms 252 KB Output isn't correct
15 Correct 2 ms 292 KB Output is correct
16 Incorrect 2 ms 380 KB Output isn't correct
17 Incorrect 2 ms 256 KB Output isn't correct
18 Incorrect 2 ms 376 KB Output isn't correct
19 Incorrect 2 ms 252 KB Output isn't correct
20 Incorrect 2 ms 256 KB Output isn't correct