# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
394451 | iulia13 | Bitwise (BOI06_bitwise) | C++14 | 1 ms | 324 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |