# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
137523 | 2019-07-28T06:06:42 Z | 송준혁(#3282) | Bitwise (BOI06_bitwise) | C++14 | 2 ms | 424 KB |
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> pii; int N, P, ans; int S[110], A[110], B[110]; bool O[110]; int main(){ scanf("%d %d", &N, &P); for (int i=1; i<=P; i++) { scanf("%d", &S[i]); S[i] += S[i-1]; } for (int i=1; i<=N; i++) scanf("%d %d", &A[i], &B[i]); for (int i=30; i>=0; i--){ bool tf=true, chk=false; memset(O, false, sizeof O); for (int j=1,k=1; j<=N; j++){ if (A[j] >= (1 << i)) { O[k] = true, chk = true; A[j] -= 1 << i, B[j] -= 1 << i; } else if (B[j] >= (1 << i)) chk = true; if (S[k] == j){ if (!chk) tf = false; chk = false, k++; } } if (tf){ ans |= 1 << i; for (int j=1,k=1; j<=N; j++){ if (A[j] < (1 << i) && B[j] >= (1 << i) && !O[k]){ O[k] = true; A[j] = 0, B[j] -= 1 << i; } if (S[k] == j) k++; } } } printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 2 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 424 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 256 KB | Output is correct |
20 | Correct | 2 ms | 256 KB | Output is correct |