QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#656607 | #9483. Maximize Array | ucup-team5319# | TL | 2ms | 11696kb | C++14 | 1.2kb | 2024-10-19 13:24:45 | 2024-10-19 13:24:55 |
Judging History
answer
//Linkwish's code
#include<bits/stdc++.h>
#define endl '\n'
#define si inline
#define fi first
#define se second
using namespace std;
typedef long long ll;typedef __int128 li;typedef long double ld;
typedef pair<int,int> pii;typedef pair<ll,ll> pll;
typedef const int ci;typedef const ll cl;ci iinf=1e9;cl linf=LLONG_MAX;
template<typename T>si bool gmax(T &x,const T y){if(x<y)return x=y,1;return 0;}
template<typename T>si bool gmin(T &x,const T y){if(y<x)return x=y,1;return 0;}
namespace LinkWish{
ci N=300005;
int n,m;
int a[N];
vector<pii> mx[N];
int note[N];
void mian(){
cin>>n>>m;
for(int i=0;i<n;i++)cin>>a[i],note[i]=mx[i%m].size(),mx[i%m].emplace_back(a[i],i);
for(int i=0;i<m;i++){
int s=mx[i].size();
for(int j=s-1;~j;j--){
if(mx[i][j+1].fi>mx[i][j].fi)mx[i][j]=mx[i][j+1];
}
}
vector<int> ans;
int cur=0;
for(;cur<n;cur++){
cur=mx[cur%m][note[cur]].se;
ans.push_back(a[cur]);
}
for(int i:ans)cout<<i<<' ';
cout<<endl;
}
}
signed main(){
#ifndef ONLINE_JUDGE
assert(freopen("in.in","r",stdin));
assert(freopen("out.out","w",stdout));
// assert(freopen("out.err","w",stderr));
#endif
LinkWish::mian();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 10808kb
input:
9 3 1 2 3 4 1 2 3 4 1
output:
4 4 1
result:
ok 3 tokens
Test #2:
score: 0
Accepted
time: 2ms
memory: 11696kb
input:
6 1 1 6 4 2 3 5
output:
6 5
result:
ok 2 tokens
Test #3:
score: 0
Accepted
time: 0ms
memory: 10604kb
input:
6 5 6 5 4 3 2 1
output:
6 5 4 3 2 1
result:
ok 6 tokens
Test #4:
score: -100
Time Limit Exceeded
input:
1392 5 915 798 656 1252 1170 691 1298 205 254 1334 622 1090 1081 617 365 477 362 1306 35 432 744 144 1277 259 80 410 317 983 916 1089 700 1030 135 156 1102 945 1021 63 251 1173 485 1261 1305 219 1190 151 142 288 795 984 1324 417 1235 1295 374 1091 434 596 553 1298 244 1179 115 767 973 315 603 180 10...