QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#793566#8158. 刷野 IILGMaster100 ✓454ms164044kbC++141.1kb2024-11-29 21:08:062024-11-29 21:08:07

Judging History

你现在查看的是最新测评结果

  • [2024-11-29 21:08:07]
  • 评测
  • 测评结果:100
  • 用时:454ms
  • 内存:164044kb
  • [2024-11-29 21:08:06]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<climits>
#include<deque> 
#define int long long
#define pii pair<int,int>
#define getchar_unlocked() getchar()
using namespace std;
const int N=5e6+5;
int d,n,x,a[N],idx,tot,ans[N];
deque<pii> q;
inline int read(){
    int s=0,f=1;
    char ch=getchar();
    while(!isdigit(ch)){
        if(ch=='-') f=-1;
        ch=getchar_unlocked();
    }
    while(isdigit(ch)){
        s=(s<<3)+(s<<1)+(ch&15);
        ch=getchar_unlocked();
    }
    return s*f;
}
signed main(){
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	d=read(),n=read();
	for(int i=1;i<=n;i++) a[i]=read(),q.push_back({i,a[i]});
	while(!q.empty()){
		++tot;
//		cout<<tot<<" ";
		pii l=q.front(),r=q.back();
		if(l.second<=r.second) ans[++idx]=l.first,q.pop_front(),x=max(x,l.second+n-tot);
		else ans[++idx]=r.first,q.pop_back(),x=max(x,r.second+n-tot);
//		cout<<l.second+n-tot<<" "<<x<<"\n";
//		cout<<r.second+n-tot<<" "<<x<<"\n";
	}
	printf("%lld\n",x);
	for(int i=idx;i>=1;i--) printf("%lld ",ans[i]);
	return 0;
}
/*
1 10
19 9 12 5 10 7 16 15 17 12
*/

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 0ms
memory: 5848kb

input:

1 10
5 9 1 5 1 4 9 2 6 4

output:

14
7 6 5 4 3 2 8 9 1 10 

result:

ok x=14

Test #2:

score: 10
Accepted
time: 1ms
memory: 5780kb

input:

2 20
4 20 2 8 16 17 8 20 15 14 3 15 19 2 9 10 4 8 20 19

output:

37
19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 20 1 

result:

ok x=37

Test #3:

score: 10
Accepted
time: 0ms
memory: 5804kb

input:

3 500
326 300 132 50 404 133 98 252 483 107 157 81 425 175 291 415 383 271 341 419 89 417 84 68 10 216 497 217 89 477 53 394 353 159 398 462 174 391 212 412 6 377 348 253 253 225 288 448 82 304 81 491 224 16 320 475 109 415 298 276 318 189 428 298 349 269 84 73 233 324 322 54 266 197 383 200 62 2 31...

output:

958
484 483 482 481 480 479 478 477 476 475 474 473 472 471 470 469 468 467 466 465 464 463 462 461 460 459 458 457 456 455 454 453 452 451 450 449 448 447 446 445 444 443 442 441 440 439 438 437 436 435 434 433 432 431 430 429 428 427 426 425 424 423 422 421 420 419 418 417 416 415 414 413 412 411 ...

result:

ok x=958

Test #4:

score: 10
Accepted
time: 0ms
memory: 5896kb

input:

4 5000
3196 2167 3085 1136 1043 3012 2853 3577 3734 2235 4640 2984 4655 1593 4129 3642 3797 1156 1642 3385 3563 1760 3328 907 151 1398 2507 3073 2492 920 528 2057 4376 879 1198 205 2919 2285 3244 2378 3414 1803 3882 4914 3344 4468 2715 2410 3749 3744 793 2876 3038 3082 3073 3575 2131 2659 4571 2178 ...

output:

9869
2203 2202 2201 2200 2199 2198 2197 2196 2195 2194 2193 2192 2191 2190 2189 2188 2187 2186 2185 2184 2183 2182 2181 2180 2179 2178 2177 2176 2175 2174 2173 2172 2171 2170 2169 2168 2167 2166 2165 2164 2163 2162 2161 2160 2159 2158 2157 2156 2155 2154 2153 2152 2151 2150 2149 2148 2147 2146 2145 ...

result:

ok x=9869

Test #5:

score: 10
Accepted
time: 6ms
memory: 10928kb

input:

5 50000
32317 40462 2286 2914 32868 9769 29248 17580 35780 9906 8732 1889 18123 40612 48036 15966 315 4239 21451 22053 12442 12900 21082 1753 35490 14732 9053 2965 35746 43074 32404 470 7723 21764 34547 40284 34355 6230 48754 10270 34837 25502 31405 24611 32848 30825 8420 41865 28964 20853 35069 897...

output:

99267
22184 22183 22182 22181 22180 22179 22178 22177 22176 22175 22174 22173 22172 22171 22170 22169 22168 22167 22166 22165 22164 22163 22162 22161 22160 22159 22158 22157 22156 22155 22154 22153 22152 22151 22150 22149 22148 22147 22146 22145 22144 22143 22142 22141 22140 22139 22138 22137 22136 ...

result:

ok x=99267

Test #6:

score: 10
Accepted
time: 37ms
memory: 23860kb

input:

6 500000
432538 33441 138436 218250 139806 50435 399010 455967 11899 102440 118587 330635 445868 462994 97124 158840 355709 137689 137988 455657 469328 83174 433558 394385 92604 337017 112427 363097 448329 290181 251494 153471 4693 1038 340222 423698 387154 434194 96415 431383 165349 135965 438345 2...

output:

998907
494296 494295 494294 494293 494292 494291 494290 494289 494288 494287 494286 494285 494284 494283 494282 494281 494280 494279 494278 494277 494276 494275 494274 494273 494272 494271 494270 494269 494268 494267 494266 494265 494264 494263 494262 494261 494260 494259 494258 494257 494256 494255...

result:

ok x=998907

Test #7:

score: 10
Accepted
time: 36ms
memory: 23092kb

input:

7 500000
446253558 412117870 446253560 446253563 390044956 446253570 446253572 446253575 446253579 446253580 446253581 446253582 446253585 446253591 446253592 446253593 446253594 446253595 446253596 446253600 446253603 446253607 446253614 446253615 446253616 446253618 446253624 433995643 446253627 4...

output:

446753557
250006 250007 250005 250004 250003 250008 250009 250002 250001 250010 250000 249999 250011 250012 249998 249997 250013 250014 250015 249996 249995 250016 250017 249994 250018 250019 250020 250021 249993 249992 249991 250022 249990 249989 249988 250023 250024 250025 249987 249986 250026 250...

result:

ok x=446753557

Test #8:

score: 10
Accepted
time: 361ms
memory: 163096kb

input:

8 5000000
1963696 3556535 2578665 1418244 4444600 4495856 3149792 4718613 560143 985208 3380208 3515647 2269308 2410848 248087 1477275 4094873 1022633 785322 4730357 45970 1892427 2744847 1716687 3064873 1893167 651204 4798108 4954420 4211829 2912214 4369221 366813 3166447 2489515 4567271 2446689 18...

output:

9992518
3241683 3241684 3241685 3241686 3241687 3241688 3241689 3241690 3241691 3241692 3241693 3241694 3241695 3241696 3241697 3241698 3241699 3241700 3241701 3241702 3241703 3241704 3241705 3241706 3241707 3241708 3241709 3241710 3241711 3241712 3241713 3241714 3241715 3241716 3241717 3241718 3241...

result:

ok x=9992518

Test #9:

score: 10
Accepted
time: 416ms
memory: 164044kb

input:

9 5000000
18496634 18496635 18031853 18496638 18496640 18496641 18496645 18496646 18496649 16733259 18496651 18496652 18496654 18496655 18496656 18496659 18496664 18496670 18496675 18255731 18496679 18371321 18496681 17138909 18496685 18496686 18496688 18496692 18496693 18496694 18496698 17849500 18...

output:

23496633
2499987 2499986 2499985 2499984 2499983 2499988 2499989 2499982 2499990 2499981 2499980 2499979 2499978 2499977 2499976 2499991 2499992 2499993 2499994 2499975 2499995 2499996 2499997 2499998 2499974 2499999 2499973 2499972 2499971 2499970 2499969 2499968 2500000 2500001 2500002 2500003 249...

result:

ok x=23496633

Test #10:

score: 10
Accepted
time: 454ms
memory: 163140kb

input:

10 5000000
488905867 488905868 488905869 488905871 488905873 488905874 488905876 488905877 488905878 488905883 488905885 488905886 488905888 488905889 488905890 488905894 488905895 488905896 488905897 488905898 488905899 488905900 488905901 488905903 488905905 488905906 488905907 488905908 488905910...

output:

493905865
2499959 2499958 2499957 2499956 2499960 2499955 2499961 2499954 2499953 2499952 2499962 2499951 2499950 2499963 2499964 2499965 2499966 2499967 2499968 2499969 2499949 2499948 2499947 2499946 2499970 2499945 2499971 2499944 2499943 2499972 2499973 2499942 2499941 2499974 2499940 2499975 24...

result:

ok x=493905865