QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#669666#9483. Maximize Arrayucup-team902#WA 3ms12344kbC++171.2kb2024-10-23 19:19:402024-10-23 19:19:42

Judging History

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

  • [2024-10-23 19:19:42]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:12344kb
  • [2024-10-23 19:19:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define fi first
#define se second
#define bg begin
cs int RLEN=1<<22|1;
char ibuf[RLEN],*ib,*ob;
inline char gc(){
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
inline int read(){
	char ch=gc();
	int res=0;bool f=1;
	while(!isdigit(ch))f^=ch=='-',ch=gc();
	while(isdigit(ch))res=(res+(res<<2)<<1)+(ch^48),ch=gc();
	return f?res:-res;
}
template<typename tp>inline void chemx(tp &a,tp b){(a<b)?(a=b):0;}
template<typename tp>inline void chemn(tp &a,tp b){(a>b)?(a=b):0;}

cs int N=300005;
int n;
int a[N],k;
vector<int> ps[N];
vector<int>ans;
int main(){
    #ifdef Stargazer
    freopen("1.in","r",stdin);
    #endif
    n=read(),k=read();
    for(int i=1;i<=n;i++)a[i]=read(),ps[a[i]].pb(i);
    int del=0;
    for(int i=n;i;i--){
        int cnt=0;
        for(int x:ps[i])if(x>del&&(k==1||(x-del)%k==1)){
            ans.pb(i);
            del=x;
        }
    }
    for(int x:ans)cout<<x<<" ";
    for(int i=del+1;i<=n;i++)cout<<a[i]<<" ";
    puts("");
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 11548kb

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: 0ms
memory: 11632kb

input:

6 1
1 6 4 2 3 5

output:

6 5 

result:

ok 2 tokens

Test #3:

score: 0
Accepted
time: 0ms
memory: 12344kb

input:

6 5
6 5 4 3 2 1

output:

6 5 4 3 2 1 

result:

ok 6 tokens

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 11340kb

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...

output:

1385 1329 1324 1304 1247 1228 1218 1210 990 834 770 145 79 38 577 1214 1089 

result:

wrong answer 2nd words differ - expected: '1386', found: '1329'