# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
389735 | cgiosy | Cake 3 (JOI19_cake3) | C++17 | 1029 ms | 151236 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;
using ll=long long;
struct cake {
int v, x;
bool operator<(cake b) const { return x<b.x; }
};
struct node {
ll v; int c, l, r;
};
int main() {
ios::sync_with_stdio(0);cin.tie(0);
int N, M;
cin>>N>>M;
cake A[N];
for(auto&[v,x]:A) cin>>v>>x;
sort(A, A+N);
node T[6200100]{};
int t=N;
for(int i=0; i<N; i++) {
int x=A[i].v, p=i, q=i+1, s=1, e=1e9;
while(s<e) {
int m=s+e>>1;
T[q].l=T[p].l, T[q].r=T[p].r;
if(x<=m) T[q].v=T[p].v, T[q].c=T[p].c, e=m, p=T[p].l, q=T[q].l=++t;
else T[q].v=T[p].v+x, T[q].c=T[p].c+1, s=m+1, p=T[p].r, q=T[q].r=++t;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |