# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
394451 | iulia13 | Bitwise (BOI06_bitwise) | C++14 | 1 ms | 324 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 <iostream>
using namespace std;
struct ura{
int x, y;
};
ura v[105];
int l[105];
int scad[105];
///2^j +....
int main()
{
int n, i, j, b, p, sol = 0;
cin >> n >> p;
for (i = 1; i <= p; i++)
{
cin >> l[i];
l[i] += l[i - 1];
}
for (i = 1; i <= n; i++)
cin >> v[i].x >> v[i].y;
for (i = 30; i >= 0; i--)
{
int ok = 1;
int put = (1 << i);
for (b = 1; b <= p && ok; b++)
{
scad[b] = 0;
ok = 0;
for (j = l[b - 1] + 1; j <= l[b]; j++)
{
if (v[j].y >= put && (!scad[b] || v[j].x >= put))
{
ok = 1;
scad[b] = j;
}
}
}
if (ok)
{
sol += put;
for (b = 1; b <= p; b++)
v[scad[b]].x = max(v[scad[b]].x, put);
}
for (j = 1; j <= n; j++)
if (v[j].x >= put)
{
v[j].x -= put;
v[j].y -= put;
}
}
cout << sol;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |