QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#731604 | #8951. 澡堂 | int_R | 0 | 266ms | 405596kb | C++14 | 2.0kb | 2024-11-10 09:51:46 | 2024-11-10 09:51:50 |
Judging History
answer
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;
const int MAXN=1e6+10;
const ll INF=1e14;
int n,m,q,t[MAXN],top,s[MAXN],f[20][MAXN];
ll T,w[MAXN],h[20][MAXN],g[20][MAXN],S,ans;
inline ll Q(int l,int r)
{
int t=__lg(r-l+1);
return max(h[t][r],h[t][l+(1<<t)-1]);
}
inline void calc(int l,int r,__int128 &now,int del=0)
{
if(l>r) return ;
if(Q(l,r)+del<=now){ans+=(r-l+1)*now;return ;}
int L=l,R=r;while(L<R)
{int m=(L+R)>>1;(Q(l,m)+del>now)?R=m:L=m+1;}
ans+=(L-l)*now;for(int i=19;~i;--i)
if(f[i][L]&&f[i][L]<=r) ans+=g[i][L],L=f[i][L];
now=w[L]+del,ans+=(r-L+1)*now;return ;
}
inline void calc(ll num,__int128 &now)
{if(num>now) now=num;ans+=now;}
inline void write(__int128 num)
{
if(!num) return ;write(num/10);
cout<<(int)(num%10);return ;
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif
cin.tie(0),cout.tie(0);
ios::sync_with_stdio(0);
cin>>n>>m>>q>>T;
for(int i=1;i<=n;++i)
{
cin>>t[i],S+=(h[0][i]=w[i]=t[i]-i*T);
for(int j=1;j<=__lg(i);++j)
h[j][i]=max(h[j-1][i],h[j-1][i-(1<<j-1)]);
}
for(int i=n;i;--i)
{
while(top&&w[s[top]]<=w[i]) --top;
g[0][i]=w[i]*((f[0][i]=s[top])-i),s[++top]=i;
for(int j=1;j<20;++j)
f[j][i]=f[j-1][f[j-1][i]],
g[j][i]=g[j-1][i]+g[j-1][f[j-1][i]];
}
for(int x,y;q;--q)
{
cin>>x>>y;__int128 now=-INF;ans=0;
int k=upper_bound(t+1,t+1+n,y)-t;
if(x<=k)
{
calc(1,x-1,now);
calc(x+1,k-1,now,T);
calc(y-1ll*(k-1)*T,now);
calc(k,n,now);
}
else
{
calc(1,k-1,now);
calc(y-1ll*(k-1)*T,now);
calc(k,x-1,now,-T);
calc(x+1,n,now);
}
write(ans-(S-t[x]+y)),cout<<'\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 108292kb
input:
1000 5 1000 1969617 59993 133807 154199 240894 438118 483699 540258 892751 922552 1049554 1092961 1153394 1287745 1315664 1372758 1550447 1634967 1817853 1825455 2023239 2064188 2117896 2250036 2453036 2492474 2794776 2917935 3047993 3153958 3163156 3237767 3443614 3664074 3716235 3801008 3822067 40...
output:
933174498561 933101766227 933105109405 933146329454 933140299260 933138339685 933106603626 933155511734 933162055060 933159866214 933132872816 933161214184 933103063660 933062469939 933188020289 933153158980 933127568756 933070267847 933085875160 933093764215 933216150562 933138725077 933172534610 9...
result:
wrong answer 1st lines differ - expected: '145473107761', found: '933174498561'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 20
Accepted
time: 223ms
memory: 405320kb
input:
1000000 1 100000 1165 83 197 266 277 299 529 538 601 629 760 792 1081 1208 1211 1387 1726 1873 1932 2198 2437 2448 2584 2715 2813 3113 3169 3207 3386 3934 4013 4032 4057 4137 4213 4396 4666 4754 4786 4856 4917 4966 5054 5124 5151 5196 5505 5548 5583 5730 5763 6031 6161 6169 6372 6446 6517 6712 6744 ...
output:
532526465394304 532526382684731 532526432382169 532526335149396 532526336776485 532526441654485 532526419072018 532526448365904 532526461590885 532526446716107 532526451559614 532526448428416 532526467783803 532526436578785 532526455446447 532526418608776 532526437618228 532526421765463 532526361938...
result:
ok 100000 lines
Test #7:
score: 0
Wrong Answer
time: 242ms
memory: 405596kb
input:
1000000 1 100000 320 81 176 196 266 277 418 437 447 561 667 671 686 708 916 945 987 1077 1147 1343 1447 1459 1622 1739 1821 1907 2052 2211 2334 2483 2502 2553 2681 2879 2899 2996 3003 3075 3089 3141 3197 3312 3411 3450 3488 3525 3711 3870 4033 4066 4103 4216 4290 4341 4406 4500 4578 4600 4655 4697 4...
output:
110078125101649 110078095701794 110078065549730 110078084700891 110078055599406 110078147872941 110078125921229 110078050034681 110078131570282 110078020684010 110078081392840 110078123741061 110078124999461 110078092777746 110078093138994 110078104230505 110078088736720 110078130160314 110078088020...
result:
wrong answer 97401st lines differ - expected: '110078111679391', found: '110078431679391'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Wrong Answer
Test #36:
score: 0
Wrong Answer
time: 266ms
memory: 404420kb
input:
1000000 5 100000 1887 112 168 223 393 535 558 577 631 631 678 682 1043 1099 1268 1337 1396 1437 1472 1510 1587 1804 1984 2013 2290 2294 2392 2474 2547 2694 2717 2742 2841 2880 2906 2985 3030 3047 3064 3108 3275 3375 3440 3451 3488 3950 3957 3963 4047 4086 4335 4378 4448 4490 4544 4622 4864 4875 4897...
output:
893584968991754 893584984212509 893585051083652 893584930600924 893584944776960 893584938734741 893584885638322 893584910752748 893584955056978 893584898092366 893584916284906 893585000107446 893585030346881 893585014845551 893584957084055 893584956579155 893584930255009 893584989576264 893584952954...
result:
wrong answer 1st lines differ - expected: '138785143191754', found: '893584968991754'
Subtask #6:
score: 0
Skipped
Dependency #3:
0%