ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#205507 | #3658. 删数游戏 | snow_trace | 100 | 492ms | 2032kb | C++11 | 1.1kb | 2024-07-07 12:52:55 | 2024-07-07 13:20:56 |
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[100005];int n;
void solve(){
cin >> n;for(int i = 1;i<=n;i++)cin >> a[i];
if(n%2 == 1){
int mid = n+1>>1;
if(a[mid]<=a[mid-1] or a[mid]<=a[mid+1])cout << a[mid] << '\n';
else cout << max(a[mid-1],a[mid+1]) << '\n';
}else{
int mid = n>>1;
cout << max(a[mid],a[mid+1]) << '\n';
}
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t;cin >> t;
while(t--){
solve();
}
return 0;
}
/*
首先很容易写出 dp。
这个 dp 长得很可爱。
偶数轮取 min 合并,奇数轮取 max 合并。
然后这个很难维护。
考虑二分答案,可以变成 01 序列。
怎么维护呢。怎么维护呢。怎么维护呢。怎么维护呢。
对于 n 是奇数的情况
如果中间是 0 就肯定是 0
否则,中间是1,如果只有这一个 1 就似了
发现如果它左边或者右边有一个就行,否则就一定不行。
对于 n 是偶数的情况
你发现中间只要有一个数是 1 就是 1
否则中间两个数都是 0
那肯定不行。
有点牛了。
*/
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1248kb
input:
10 3 613758771 356937637 286925413 3 309635201 4119573 12672577 3 908539837 376256867 673742215 3 25...
output:
356937637 4119573 376256867 29280187 378806137 500071651 148732984 491253760 231506155 208737943
result:
ok 10 lines
Test #2:
score: 10
Accepted
time: 0ms
memory: 1244kb
input:
10 3 10931386 117297147 159933961 3 90337741 212594593 98873674 3 129454241 303988881 730905561 3 75...
output:
117297147 98873674 303988881 15612529 356387186 550811017 407438865 51789077 107735813 151748426
result:
ok 10 lines
Test #3:
score: 10
Accepted
time: 0ms
memory: 1260kb
input:
10 1000 167905485 208763751 138626601 932784449 228519721 282400288 132186355 15872271 92282711 1325...
output:
403988845 457552801 388265001 10811020 705772900 114763687 659759507 307132303 354245321 52388641
result:
ok 10 lines
Test #4:
score: 10
Accepted
time: 0ms
memory: 1260kb
input:
10 1000 106935067 125402369 613861873 127608150 118554097 28464487 542845281 156683332 14063068 3248...
output:
141900130 846636441 649729872 24210741 613578049 243179119 546303628 238813241 105984529 610132501
result:
ok 10 lines
Test #5:
score: 10
Accepted
time: 1ms
memory: 1256kb
input:
10 1000 411526119 637006177 911588822 496496161 61356302 111514144 542096029 760634253 672439501 662...
output:
461178612 567420205 376347565 196693046 209902232 329106989 136551481 962827830 235347389 593955181
result:
ok 10 lines
Test #6:
score: 10
Accepted
time: 95ms
memory: 2028kb
input:
10 100000 718749825 746785710 27749441 41444821 259131727 172557178 793955441 99599666 163197987 188...
output:
297493249 413115093 708045870 716500401 175485168 799161715 700496161 460682083 241487782 70418526
result:
ok 10 lines
Test #7:
score: 10
Accepted
time: 103ms
memory: 2028kb
input:
10 100000 27978370 4374151 754505581 132813041 320978233 345428200 623829321 71676746 291401501 1585...
output:
104182345 309479031 328440619 146794570 265110993 411769891 633244971 501695415 196061569 544061920
result:
ok 10 lines
Test #8:
score: 10
Accepted
time: 103ms
memory: 2028kb
input:
10 100000 798861877 388220845 79152789 386994909 245031499 68960243 96481409 432630870 15115816 8533...
output:
195962218 260552755 911776641 402660721 119793143 274866561 314728574 503302149 753573121 792835121
result:
ok 10 lines
Test #9:
score: 10
Accepted
time: 97ms
memory: 2032kb
input:
10 100000 499504565 41637903 385913456 724832195 97810294 237878941 44757307 19358717 822946397 6529...
output:
300631009 536510449 579244986 735966766 125851446 712283829 113242101 622967187 165130096 203337377
result:
ok 10 lines
Test #10:
score: 10
Accepted
time: 93ms
memory: 2032kb
input:
10 100000 30813538 582753601 68526921 602383881 25599691 58344973 337240 254442202 56661307 10202082...
output:
387102581 429962248 434239070 27726119 309516446 534466201 454709979 519867587 336570310 80091964
result:
ok 10 lines