QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#208782 | #6767. Hourly Coding Problem | 275307894a | RE | 1730ms | 12108kb | C++14 | 1.7kb | 2023-10-09 20:55:51 | 2023-10-09 20:55:52 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=2e5+5,M=N*4,K=600+5,mod=1e9+7,Mod=mod-1;const db eps=1e-6;const ll INF=1e18+7;mt19937 rnd(263082);
int n,k;ll A[N],l[N],r[N];
struct BIT{
ll f[M];
void Cl(){fill(f+1,f+n+1,-INF);}
void add(int x,ll y){while(x<=n+1) f[x]=max(f[x],y),x+=x&-x;}
int qry(ll y){int x=0;for(int i=17;~i;i--) if(x+(1<<i)<=n+1&&f[x+(1<<i)]<y) x+=(1<<i);return x+1;}
}f1,f2;
int CK(ll mid){
l[0]=r[0]=0;int i,j;
f1.Cl();f2.Cl();f1.add(1,A[0]);f2.add(n+1,A[0]);
for(i=1;i<=n;i++){
l[i]=f1.qry(A[i]-mid);r[i]=n+1-f2.qry(A[i]-mid)+1;
if(l[i]<=n) f1.add(l[i]+1,A[i]),f2.add(n+1-r[i],A[i]);
// for(j=0;j<i;j++) if(A[i]-mid<=A[j]) l[i]=min(l[i],l[j]+1),r[i]=max(r[i],r[j]+1);
}
return l[n]<=k&&k<=r[n];
}
void find(int x,int y,ll mid){
if(!x){assert(!y);return;}
for(int i=0;i<x;i++) if(A[x]-A[i]<=mid&&l[i]<=y-1&&y-1<=r[i]) {printf("%d%c",x-i," \n"[y==1]);find(i,y-1,mid);return;}
assert(0);
}
void Solve(){
int i,j;scanf("%d%d",&n,&k);
for(i=1;i<=n;i++) scanf("%lld",&A[n-i+1]);for(i=1;i<=n;i++) A[i]+=A[i-1];
ll l=-INF,r=INF,mid;while(l+1<r) mid=l+r>>1,(CK(mid)?r:l)=mid;
CK(r);find(n,k,r);
}
int main(){
int t=1;
scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 10052kb
input:
3 7 3 5 1 0 2 7 -3 4 6 4 -1 3 -2 4 -3 5 6 2 0 -2 0 -1 -1 0
output:
3 3 1 1 1 2 2 3 3
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 973ms
memory: 9972kb
input:
200178 2 1 5 -1 4 3 4 -7 -4 10 2 1 -6 -2 4 1 8 10 -9 10 4 2 10 -4 10 1 4 1 7 -1 4 3 4 1 7 -5 10 10 2 1 -7 9 3 2 3 3 4 4 4 -1 4 -9 -8 3 1 10 6 7 2 2 3 8 4 4 0 -9 -2 -9 2 1 9 -3 1 1 -3 3 3 -8 -7 -3 4 3 -2 -3 3 1 4 4 7 -5 4 0 3 2 2 6 3 5 1 7 -3 2 3 0 4 1 10 -8 -8 -4 1 1 -2 1 1 -2 3 2 1 -9 -5 2 1 -6 4 1...
output:
2 1 1 2 2 4 1 3 4 4 2 2 1 1 1 1 1 3 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 2 1 5 4 1 1 2 1 2 1 1 3 1 1 1 1 1 1 1 2 1 1 2 3 1 1 2 1 1 1 1 1 2 1 4 5 1 1 1 1 1 1 1 2 2 1 1 5 1 2 1 3 1 5 1 1 2 1 4 4 1 3 1 1 1 1 1 1 3 1 1 1 1 1 1 1 3 2 1 1 1 1 1 1 4 1 1 1 2 2 1 2 1 1 1 1 1 3 1 3 1 1 1 1 1 1 2 1 2 2 2 3 2 3 ...
result:
ok 200178 lines
Test #3:
score: 0
Accepted
time: 1028ms
memory: 12008kb
input:
199772 5 3 -46052578 659867356 -845691509 354080848 495499331 3 2 -723935257 710677961 444019907 2 2 -630160659 -152028149 2 1 588799363 -240251692 1 1 -194483310 3 3 374813337 273066639 -351814252 3 2 -730564958 797633747 637128587 4 4 -307084294 -676969505 558588609 -844837130 2 2 223904090 -50221...
output:
3 1 1 2 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 1 1 2 1 1 1 1 1 5 3 2 1 1 1 1 3 1 4 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 5 1 2 1 2 3 3 1 1 1 1 4 1 1 1 1 1 2 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 3 1 1 1 1 1 1 1 2 1 2 3 4 1 2 2 1 1 2 1 ...
result:
ok 199772 lines
Test #4:
score: 0
Accepted
time: 978ms
memory: 9972kb
input:
46211 17 3 6 3 0 5 -10 6 -4 10 5 -9 -7 9 8 0 3 1 -4 12 1 -6 -2 -10 10 5 5 5 7 6 -10 4 2 1 1 1 3 3 8 6 1 21 4 3 10 10 0 -5 -3 -1 -9 -10 -4 1 -5 -8 -8 -4 8 9 -4 -7 -6 3 21 1 0 2 8 5 -8 -8 3 -1 6 1 -7 4 2 3 8 -3 -8 5 -6 7 1 1 1 -9 25 1 0 -3 -3 5 6 -4 -1 -8 -9 0 4 5 4 9 -5 -9 -5 -1 -8 1 3 6 9 -7 -1 17 5...
output:
7 5 5 12 1 1 1 1 11 1 6 3 21 1 25 7 7 1 1 1 2 1 11 9 1 1 1 1 1 1 1 6 1 1 3 6 3 1 17 3 6 3 1 3 4 1 5 2 10 5 1 6 9 1 1 11 1 2 1 1 1 1 1 1 1 1 1 2 8 5 8 1 13 4 1 1 9 11 1 2 3 5 3 1 6 19 1 4 1 2 1 16 9 1 1 1 1 15 6 20 6 7 7 3 3 17 1 2 14 4 4 7 8 1 10 2 6 1 1 1 5 2 4 1 1 1 7 2 2 4 3 1 7 1 1 3 1 10 1 2 3 ...
result:
ok 46211 lines
Test #5:
score: 0
Accepted
time: 1004ms
memory: 12108kb
input:
46128 15 3 -76 84 71 66 5 12 -34 82 50 -70 -96 80 -99 42 67 6 1 -93 78 -68 -97 -31 7 10 2 49 -46 -80 -36 -36 -42 -17 35 36 -81 12 4 80 -6 81 -17 -56 88 12 56 62 -79 84 7 22 1 32 13 5 100 37 -36 47 -73 -99 9 -46 27 68 1 -70 -30 -5 74 97 6 50 -29 20 2 -22 9 -77 -66 -28 36 54 34 32 55 9 -85 -94 -29 14 ...
output:
13 1 1 6 4 6 2 1 5 4 22 15 5 1 5 4 1 8 1 2 2 4 3 1 3 12 18 7 4 2 10 1 2 1 1 1 2 5 2 8 3 6 1 5 9 6 2 5 4 1 14 3 1 19 3 1 9 1 2 2 2 21 2 6 2 10 3 7 1 4 1 1 3 1 3 2 4 10 4 4 10 1 1 1 2 2 11 10 2 1 5 10 6 2 19 2 20 3 1 1 1 1 1 1 3 7 2 8 1 1 1 1 3 1 3 1 1 21 19 4 2 2 1 2 7 3 8 3 1 5 6 1 1 1 1 9 2 25 4 4 ...
result:
ok 46128 lines
Test #6:
score: 0
Accepted
time: 1021ms
memory: 12032kb
input:
46275 8 3 46093769 -773754553 -392699827 -541568835 749997067 173070491 194887177 -791837957 10 3 -399615581 -974676777 572713394 -115419320 269846582 65640637 415752922 734872927 -935606077 -460599602 14 5 -272962438 -201008512 -221240850 914999800 -819437270 -35566423 709695488 -191248867 80608304...
output:
2 1 5 1 5 4 1 3 5 2 3 7 2 1 7 12 1 7 4 6 1 12 1 2 1 3 3 2 2 2 11 1 3 1 1 12 9 1 6 2 11 1 3 13 6 2 1 2 14 9 11 5 3 1 1 5 2 1 2 5 4 8 2 3 7 1 1 2 8 1 8 1 4 11 1 9 1 2 1 17 1 5 1 4 1 1 1 4 1 1 1 4 4 4 1 1 18 9 1 4 3 11 3 3 1 1 1 13 1 16 1 3 2 1 1 1 4 2 6 8 1 1 3 11 4 1 1 1 1 11 1 1 2 1 4 1 2 1 1 1 12 6...
result:
ok 46275 lines
Test #7:
score: 0
Accepted
time: 1051ms
memory: 12020kb
input:
46255 20 7 1 1 -8 -3 1 -1 -4 -2 -7 -3 7 -9 -10 10 -10 -3 2 10 -4 7 22 10 -4 -3 0 -8 -8 6 10 -4 6 8 -7 5 1 0 6 6 -6 -10 -3 -9 -9 -6 8 4 6 9 -10 -6 9 -6 10 9 12 6 4 -7 -4 -7 -3 -10 -1 0 4 -1 10 8 8 6 4 10 2 -2 5 7 -8 -10 17 1 10 -5 -6 7 -4 -7 6 -10 7 -5 -9 -10 1 4 7 8 -3 9 7 6 -6 3 0 4 -8 -6 1 2 22 5 ...
output:
3 2 1 1 1 3 9 2 1 4 2 2 7 1 1 1 1 4 1 2 1 2 1 1 1 6 1 1 3 1 1 1 1 17 2 1 1 2 1 1 1 2 7 11 1 1 1 1 1 1 1 1 2 2 1 1 2 1 3 1 3 3 1 2 1 3 3 13 2 3 4 11 4 4 6 2 3 1 1 2 1 4 2 1 2 6 2 2 1 1 3 10 4 1 1 6 1 2 1 1 1 7 1 1 1 1 3 1 5 1 1 1 2 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1...
result:
ok 46255 lines
Test #8:
score: 0
Accepted
time: 1064ms
memory: 9896kb
input:
46177 24 20 25 14 -46 -61 -64 10 53 -80 -11 91 -59 43 48 -90 -82 -12 -25 72 99 -44 99 21 -92 5 13 12 58 24 -35 93 3 -96 42 6 -43 71 -12 -22 -8 2 1 -1 0 2 1 -93 80 14 3 -86 72 -65 14 -56 -2 -39 43 -87 29 -39 -15 -58 -33 20 4 50 -56 -5 13 -36 -18 73 -64 19 4 44 -58 -98 -44 14 93 63 56 -12 27 2 2 -32 -...
output:
1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 2 3 1 1 1 2 1 1 1 1 1 1 1 1 1 2 2 8 3 3 7 4 7 2 1 1 1 2 1 1 1 2 1 3 1 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 3 2 1 1 1 1 1 1 1 1 1 1 3 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 4 1 1 4 2 2 2 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 5 1 1 1 1 1 3 2 1 4 2 2 1 1 1 1 1 1 1 1 1 1 8 2 2 1 ...
result:
ok 46177 lines
Test #9:
score: 0
Accepted
time: 1102ms
memory: 9892kb
input:
46053 7 2 805503116 -146327397 724584190 939057367 563892810 -321631878 772845285 11 8 -912954459 832035093 613578959 117809616 -850489232 -122333651 247540838 -724606797 -942073171 656161804 14899908 3 2 615417815 642804724 -313818109 20 14 451783792 -731819844 180260358 -9034098 -798871547 2308456...
output:
3 4 3 1 1 1 1 1 2 1 1 2 2 1 1 3 1 1 1 3 2 1 1 1 1 1 9 2 1 2 1 13 1 2 1 6 5 1 1 4 1 5 1 2 1 1 1 1 1 1 1 2 4 1 6 7 1 2 1 2 1 3 4 1 1 3 1 9 11 4 3 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 1 5 2 3 2 2 13 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 5 1 1 4 1 1 2 1 1 2 1 3 1 1 1 4 1 1 1 1 1 1 4 2 1 2 2 1...
result:
ok 46053 lines
Test #10:
score: 0
Accepted
time: 1294ms
memory: 12000kb
input:
1484 224 6 -1 5 6 -6 2 -3 9 -7 5 -5 10 -9 -7 5 -5 3 -8 10 -10 -10 -9 -6 10 -10 8 0 -7 -2 -8 10 10 3 -9 -3 -6 -9 0 7 2 -3 4 -3 9 8 9 -1 10 4 0 -3 -4 -6 -4 -5 0 -8 -5 7 0 1 6 -9 -2 -4 0 -5 -10 -5 -5 -6 -10 2 4 -5 6 7 -8 4 -7 -5 -2 -9 -3 -3 4 7 6 -10 -10 9 5 4 9 3 -6 -6 4 -9 -10 9 6 4 6 2 7 -5 4 -9 6 1...
output:
13 2 35 158 15 1 1 1 1 2 75 1 1 1 1 1 2 5 2 86 52 1 12 383 1 3 3 1 1 8 1 4 5 23 2 14 2 7 6 1 15 1 69 1 8 49 18 1 1 4 4 15 7 150 12 91 10 1 2 1 3 2 13 6 2 58 9 52 10 10 299 22 105 3 67 82 1 1 3 18 9 1 3 3 1 4 20 5 2 2 1 2 1 190 19 19 17 95 9 1 19 5 25 4 4 2 1 2 2 1 1 1 2 1 8 3 1 1 1 1 1 1 1 135 4 8 2...
result:
ok 1484 lines
Test #11:
score: 0
Accepted
time: 1367ms
memory: 9980kb
input:
1465 606 1 39 59 87 5 9 -41 -57 60 -100 -10 98 27 -12 32 70 -35 -42 90 70 -19 81 99 -95 11 -37 0 -24 -37 -97 -35 94 33 -34 -11 -52 -4 -79 90 -96 -71 63 56 -15 85 -100 -18 3 44 -98 -7 100 -12 -23 -9 47 14 60 45 45 31 90 52 17 -66 33 -44 -90 41 21 88 77 -67 -20 -1 31 71 -14 -35 17 63 77 -74 67 28 -10 ...
output:
606 42 1 2 1 1 1 1 1 2 1 2 1 2 2 2 7 53 2 10 352 4 18 18 29 5 2 45 155 23 1 2 17 188 8 2 2 15 5 19 23 3 10 2 1 5 61 39 50 36 22 17 2 1 153 2 1 1 2 24 13 1 1 21 19 59 169 26 172 181 3 3 1 1 1 4 5 4 2 1 1 2 2 1 1 1 1 1 6 1 498 6 50 71 2 5 17 1 1 50 3 43 135 38 57 7 70 7 117 44 45 76 8 96 1 1 2 1 1 1 1...
result:
ok 1465 lines
Test #12:
score: 0
Accepted
time: 1426ms
memory: 12008kb
input:
1460 546 3 658046175 -153056819 993594004 -307492377 783530689 -920895317 421336842 -551546676 726055988 405820903 397691023 583404123 407016259 -466043024 521449185 581996267 -987957699 -590939939 419390615 107781512 9270849 -8289046 -747348994 -565218247 -484175938 406091392 -45695774 710403629 -6...
output:
385 151 10 134 6 1 1 31 6 12 1 9 6 6 2 14 1 4 43 1 3 12 1 7 2 1 6 2 56 14 35 139 56 16 46 265 279 6 85 2 19 25 1 8 2 81 6 1 1 2 7 2 5 1 4 567 3 1 1 1 1 1 1 2 1 2 411 2 1 3 1 5 17 1 5 1 21 7 22 2 1 1 9 11 2 2 1 2 1 1 1 180 13 7 18 1 2 5 14 19 10 1 1 1 1 1 2 3 1 1 1 1 1 3 1 1 2 27 1 1 1 1 1 18 8 4 10 ...
result:
ok 1460 lines
Test #13:
score: 0
Accepted
time: 1712ms
memory: 10004kb
input:
1506 297 273 1 6 10 -9 -4 3 7 5 9 -5 -1 8 -1 -2 6 8 4 -9 7 10 -3 6 -9 -3 9 5 8 0 -4 10 -2 -10 -10 8 -6 -9 8 -8 9 9 -8 -4 -10 9 0 4 -3 1 8 6 3 5 5 -7 7 2 7 -5 -7 3 -7 -5 0 2 0 0 6 -3 10 3 -10 -6 6 -4 7 0 3 10 1 -9 -8 -7 3 8 9 0 10 6 5 6 10 -10 6 -7 -10 -1 -9 2 -2 -9 2 1 -8 -9 -2 7 -9 3 -10 -6 5 7 9 -...
output:
6 1 4 3 4 6 1 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 1506 lines
Test #14:
score: 0
Accepted
time: 1730ms
memory: 11968kb
input:
1487 324 141 76 -83 -28 -6 -22 12 -57 -68 -32 -58 15 -99 64 78 -83 -23 -100 0 7 -9 37 -8 -58 9 71 70 -18 80 81 -59 12 -54 98 -64 -23 -66 61 95 -86 -70 -9 -36 -9 83 -100 78 -22 -87 -100 -73 -65 18 77 36 62 -56 16 -4 -67 46 84 91 -97 19 25 13 -8 -7 -1 -11 69 -22 97 61 8 -20 -35 79 25 -66 -2 29 22 85 -...
output:
2 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 3 2 9 4 1 3 2 27 3 2 1 1 1 1 1 2 2 35 2 1 1 1 1 1 1 1 1 1 3 1 1 2 1 1 1 1 1 1 1 2 2 1 1 1 2 1 1 1 1 3 1 1 1 4 1 2 1 1 1 1 1 9 1 20 2 10 1 3 1 6 1 1 1 1 20 2 1 1 1 1 1 3 1 1 2 3 2 1 2 1 1 2 1 2 1 1 8 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 2 1 1 2 1 1 1 5 9 3 4 1 9...
result:
ok 1487 lines
Test #15:
score: 0
Accepted
time: 1713ms
memory: 11948kb
input:
1499 36 24 -197283523 -786183498 -96271709 813345380 71616465 132254580 523459299 825723706 -576026433 -422692207 717919262 -883763793 122617446 -736834473 -58061051 -186261661 -132285261 -441378540 -688446748 487454379 -534261510 109982914 -407316090 105208594 822771874 -735690635 979546693 -998459...
output:
6 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 2 2 2 1 3 2 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
result:
ok 1499 lines
Test #16:
score: -100
Runtime Error
input:
3 85841 2 4 -3 -10 -3 10 -9 7 8 7 -1 -2 4 -3 6 -8 -4 -2 0 4 1 4 -6 -5 3 5 10 2 4 -6 -1 1 4 3 3 1 -7 9 1 -8 0 5 -6 -1 8 10 9 -10 -4 -2 -2 -4 -6 -10 7 -9 8 -8 -10 5 -6 5 3 6 -10 8 8 9 2 -4 -4 3 -6 -7 -10 10 7 -7 -4 -9 -4 0 8 -1 10 4 4 0 -7 6 3 4 9 1 1 -1 8 7 -5 -3 -1 -1 0 3 -3 7 10 8 -10 -3 -10 1 7 4 ...