QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#624102 | #4095. 날다람쥐 | Matutino | 0 | 0ms | 24328kb | C++17 | 2.5kb | 2024-10-09 14:58:12 | 2024-10-09 14:58:12 |
Judging History
answer
#include "squirrel.h"
#include<bits/stdc++.h>
#define reg register
#define int long long
inline int min(reg int x,reg int y){return x<y?x:y;}
inline bool cmin(reg int &x,reg int y){return x>y?x=y,1:0;}
inline bool cmax(reg int &x,reg int y){return x<y?x=y,1:0;}
const int N=5e5+10;
int n,mn[N<<2],tag[N<<2],st[20][N],w[N];
inline void brush(reg int o,reg int k){mn[o]+=k,tag[o]+=k;}
inline void pushdown(reg int o){if (tag[o]) brush(o<<1,tag[o]),brush(o<<1|1,tag[o]),tag[o]=0;}
inline void pushup(reg int o){mn[o]=min(mn[o<<1],mn[o<<1|1]);}
void modify(reg int o,reg int l,reg int r,reg int L,reg int R,reg int k){
if (L<=l&&r<=R) return brush(o,k); reg int mid=l+r>>1; pushdown(o);
if (L<=mid) modify(o<<1,l,mid,L,R,k); if (R>mid) modify(o<<1|1,mid+1,r,L,R,k); pushup(o);
}
int find(reg int o,reg int l,reg int r,reg int x){
if (mn[o]>0) return l-1; if (l==r) return l; pushdown(o);
reg int mid=l+r>>1,t=x>mid?find(o<<1|1,mid+1,r,x):mid;
return t==mid?find(o<<1,l,mid,x):t;
}
int query(reg int o,reg int l,reg int r,reg int L,reg int R){
if (L<=l&&r<=R) return mn[o]; reg int mid=l+r>>1,res=1e18; pushdown(o);
if (L<=mid) cmin(res,query(o<<1,l,mid,L,R)); if (R>mid) cmin(res,query(o<<1|1,mid+1,r,L,R));
return res;
}
inline int chk(reg int x,reg int y){return w[x]<w[y]?x:y;}
inline int qry(reg int l,reg int r){reg int L=std::__lg(r-l+1); return chk(st[L][l],st[L][r-(1<<L)+1]);}
#undef int
long long fly(std::vector<int> D, std::vector<int> H, std::vector<int> W, int L, int R) {
#define int long long
n=D.size();
for (reg int i=1;i<=n;i++) st[0][i]=i,w[i]=W[i-1];
for (reg int j=1;1<<j<=n;j++) for (reg int i=1;i+(1<<j)-1<=n;i++) st[j][i]=chk(st[j-1][i],st[j-1][i+(1<<j-1)]);
reg int ans=0; D.push_back(D.back()+R);
modify(1,1,n,1,1,H[0]-L);
for (reg int i=2,now=L;i<=n+1;i++){
reg int d=D[i-1]-D[i-2];
// std::cerr<<"<< "<<d<<" "<<now<<"\n";
reg int qwq=0;
while (now<d){
++qwq; assert(qwq<=4);
// std::cerr<<"qwq\n";
reg int L=find(1,1,n,i-1)+1;
// std::cerr<<L<<" "<<i<<"\n";
if (L==i) return -1;
reg int nw=min(query(1,1,n,L,i-1),d-now);
// std::cerr<<query(1,1,n,3,3)<<"\n";
reg int id=qry(L,i-1); modify(1,1,n,id,i-1,-nw);
ans+=w[id]*nw,now+=nw;
}
now-=d;
// std::cerr<<now<<"\n";
cmin(now,H[i-1]);
if (i<=n) modify(1,1,n,i,i,H[i-1]-now);
}
return ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
500000 0 74201083 0 1894 103949999 0 1976 991641614 0 6829 836886815 0 7228 145466667 0 8362 872980184 0 12946 992583286 0 15616 517178776 0 16265 554052070 0 17815 316840754 0 17968 707530952 0 20234 453750281 0 20430 600152122 0 20883 596429721 0 20904 475724209 0 21127 592035055 0 21432 661316980...
output:
Unauthorized output
result:
Subtask #2:
score: 0
Runtime Error
Test #16:
score: 13
Accepted
time: 0ms
memory: 10256kb
input:
3 0 8 1 2 4 1 4 9 1 7 5
output:
3 jP0CvdiJvC0xnBnhWA0Okzbk OK
result:
ok 3 lines
Test #17:
score: 13
Accepted
time: 0ms
memory: 9892kb
input:
3 0 8 1 3 6 1 5 9 1 7 0
output:
0 jP0CvdiJvC0xnBnhWA0Okzbk OK
result:
ok 3 lines
Test #18:
score: 0
Runtime Error
input:
500000 0 880898257 1 449 697805005 1 832 732167074 1 1215 76849645 1 1235 794467866 1 1420 214671183 1 5637 797829256 1 8769 882665474 1 9532 129301213 1 10004 585069308 1 12187 307040559 1 15062 932082580 1 15573 153996345 1 16803 883017734 1 17855 868527578 1 21933 326154227 1 26329 938464658 1 26...
output:
Unauthorized output
result:
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Runtime Error
Test #54:
score: 15
Accepted
time: 0ms
memory: 9888kb
input:
3 0 5 3 2 6 2 8 4 1 4 2
output:
10 jP0CvdiJvC0xnBnhWA0Okzbk OK
result:
ok 3 lines
Test #55:
score: 15
Accepted
time: 0ms
memory: 24328kb
input:
500 0 36 477870592 1 49 225118723 2 12 305549731 3 50 199782350 4 12 621067277 5 17 634339441 6 33 724737436 7 44 600042161 8 50 270266672 9 45 325722239 10 24 344756214 11 47 280078638 12 31 289312397 13 30 577859437 14 29 99532301 15 12 765519665 16 14 729669577 17 33 859013484 18 45 377019268 19 ...
output:
29696474768 jP0CvdiJvC0xnBnhWA0Okzbk OK
result:
ok 3 lines
Test #56:
score: 0
Runtime Error
input:
500 0 44 435213639 1 30 653422811 2 14 397819976 3 25 81288885 4 14 534643415 5 40 727614621 6 34 232508110 7 29 937246678 8 26 809838502 9 19 671612396 10 23 440663685 11 34 636252166 12 40 408340232 13 45 295446844 14 34 78416008 15 29 349723822 16 28 862774834 17 49 221362227 18 21 21820877 19 27...
output:
Unauthorized output
result:
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%