QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#191648#880. Film CriticsZhouShangWA 1ms5572kbC++14560b2023-09-30 06:28:182023-09-30 06:28:19

Judging History

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

  • [2023-09-30 06:28:19]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5572kb
  • [2023-09-30 06:28:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m,k,A[1<<20],s,l,r,x;
pair<int,int>p[1<<20];
int main(){
	cin>>n>>m>>k;
	if(k%m!=0||k==0)
		cout<<"impossible\n",exit(0);
	k/=m;
	for(int i=1;i<=n;i++)
		cin>>x,p[i]={x,i};
	sort(p+1,p+n+1),l=k-1,r=k+1,A[1]=p[k].second,s=1;
	for(int i=2;i<=n;i++){
		if(l&&s*m>p[l].first*(i-1)){
			A[i]=p[l--].second;
			continue;
		}
		if(r<=n&&s*m<=p[r].first*(i-1)){
			A[i]=p[r++].second,s++;
			continue;
		}
		cout<<"impossible\n",exit(0);
	}
	for(int i=1;i<=n;i++)
		cout<<A[i]<<" \n"[i==n];
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5460kb

input:

5 10 30
10 5 3 1 3

output:

5 3 4 2 1

result:

ok OK!

Test #2:

score: 0
Accepted
time: 1ms
memory: 5468kb

input:

5 5 20
5 3 3 3 3

output:

impossible

result:

ok OK!

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 5572kb

input:

5 10 20
6 1 9 3 2

output:

impossible

result:

wrong answer Contestant printed 'impossible', but an answer existed.