# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
137628 | khsoo01 | Bitwise (BOI06_bitwise) | C++11 | 2 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m, k[N], s[N], e[N], ans;
bool dn[N];
bool can (int I) {
bool R = true;
for(int i=1;i<=m;i++) {
if(dn[i]) continue;
bool F = false;
for(int j=k[i-1]+1;j<=k[i];j++) {
if(e[j] >= I) F = true;
}
if(!F) {
R = false;
break;
}
}
for(int i=1;i<=m;i++) {
int C1 = 0, C2 = 0;
for(int j=k[i-1]+1;j<=k[i];j++) {
if(e[j] >= I) {
e[j] -= I;
if(s[j] >= I) {
C1++;
s[j] -= I;
}
else {
C2++;
s[j] = 0;
}
}
}
if((!R && C2) || (C1 + C2 > 1 && C2)) dn[i] = true;
}
return R;
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++) {
scanf("%d",&k[i]);
k[i] += k[i-1];
}
for(int i=1;i<=n;i++) {
scanf("%d%d",&s[i],&e[i]);
}
for(int i=(1<<30);i;i/=2) {
if(can(i)) ans += i;
}
printf("%d\n", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |