# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
137630 | 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 C = 0, D = 0;
for(int j=k[i-1]+1;j<=k[i];j++) {
if(e[j] >= I) {
C++;
if(s[j] < I) D++;
e[j] -= I;
s[j] -= min(s[j], I);
}
}
if(D && (!R || C > 1)) 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... |