QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#40317#880. Film CriticsWu_RenRE 3ms5692kbC++14699b2022-07-20 11:09:502022-07-20 11:09:53

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-20 11:09:53]
  • 评测
  • 测评结果:RE
  • 用时:3ms
  • 内存:5692kb
  • [2022-07-20 11:09:50]
  • 提交

answer

#include <bits/stdc++.h>
#define No() puts("impossible"),exit(0)
#define fi first
#define se second
using namespace std;
set<pair<int,int> >s;
int n,m,k,ans[200010];
pair<int,int>a[200010];
int main(){
//	ios::sync_with_stdio(0);
	cin>>n>>m>>k;
	if(k%m) No();
	for(int i=1,w;i<=n;i++){
		cin>>a[i].fi,a[i].se=i;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n-k/m;i++) s.insert(a[i]);
	int nw=0;
	for(int i=1,j=n-k/m+1;i<=n;i++){
		if(j<=n&&nw<=a[j].fi*(i-1)){
			ans[i]=a[j++].se,nw+=m;
			continue;
		}
		auto it=s.lower_bound({(nw+i-2)/(i-1),1000000000});
		if(it==s.begin()) No();
		--it;
		ans[i]=it->se,s.erase(it);
	}
	for(int i=1;i<=n;i++) cout<<ans[i]<<" ";cout<<"\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3624kb

input:

5 10 30
10 5 3 1 3

output:

5 3 2 1 4 

result:

ok OK!

Test #2:

score: 0
Accepted
time: 3ms
memory: 3592kb

input:

5 5 20
5 3 3 3 3

output:

impossible

result:

ok OK!

Test #3:

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

input:

5 10 20
6 1 9 3 2

output:

1 4 3 5 2 

result:

ok OK!

Test #4:

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

input:

5 10 20
5 3 10 7 10

output:

3 5 4 1 2 

result:

ok OK!

Test #5:

score: 0
Accepted
time: 2ms
memory: 3608kb

input:

5 10 30
1 0 1 8 5

output:

3 1 5 4 2 

result:

ok OK!

Test #6:

score: 0
Accepted
time: 2ms
memory: 3516kb

input:

5 10 30
2 0 5 4 2

output:

5 1 2 4 3 

result:

ok OK!

Test #7:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

100 10 100
10 10 4 8 10 0 7 8 3 3 2 3 1 8 1 5 0 0 3 3 7 10 10 5 1 9 4 3 4 5 6 5 2 7 5 6 5 0 4 9 7 0 6 5 8 0 9 3 2 3 0 4 4 10 9 0 1 0 2 3 1 5 3 8 0 1 10 7 2 10 3 9 3 10 7 7 0 7 1 6 6 3 7 7 6 9 10 8 3 1 7 9 10 9 8 5 5 0 8 4

output:

impossible

result:

ok OK!

Test #8:

score: 0
Accepted
time: 2ms
memory: 5636kb

input:

100 10 500
6 3 9 7 6 9 0 9 2 8 1 3 1 6 1 0 5 9 5 0 8 6 6 6 4 5 9 10 9 1 4 6 4 7 0 2 10 6 8 3 10 10 10 6 4 2 9 1 3 7 6 8 2 9 8 7 8 2 4 0 0 4 0 1 8 3 9 3 3 9 5 5 5 10 5 0 2 1 7 3 1 1 7 3 10 8 6 1 4 2 9 2 2 7 7 9 8 9 3 10

output:

75 73 1 72 5 14 71 22 26 23 24 19 32 17 38 44 89 51 62 87 4 34 50 56 79 83 94 59 95 10 21 39 52 55 57 65 86 97 3 6 8 18 27 29 47 54 67 70 91 96 98 28 37 41 42 43 74 85 100 45 33 31 25 99 84 80 69 68 66 49 40 12 2 93 92 90 77 58 53 46 36 9 88 82 81 78 64 48 30 15 13 11 76 63 61 60 35 20 16 7 

result:

ok OK!

Test #9:

score: 0
Accepted
time: 2ms
memory: 3520kb

input:

100 10 700
4 1 4 5 1 0 5 4 10 1 1 7 3 5 9 7 10 8 0 5 3 5 10 3 6 6 3 7 8 9 2 5 7 7 7 2 2 5 5 1 8 5 9 9 7 9 0 8 7 4 0 1 7 7 0 5 4 2 10 5 6 0 6 4 7 7 3 0 8 8 10 0 3 6 9 7 9 9 1 5 5 1 3 7 6 2 4 1 6 5 10 7 1 9 2 10 8 10 6 2

output:

73 67 27 24 83 1 21 13 3 100 8 95 86 50 58 57 37 36 64 31 87 4 7 14 20 93 22 88 32 82 38 79 39 52 42 40 56 11 60 10 80 5 81 2 90 25 26 61 63 74 85 89 99 12 16 28 33 34 35 45 49 53 54 65 66 76 84 92 18 29 41 48 69 70 97 15 30 43 44 46 75 77 78 94 9 17 23 59 71 91 96 98 72 68 62 55 51 47 19 6 

result:

ok OK!

Test #10:

score: 0
Accepted
time: 2ms
memory: 3652kb

input:

1 1234 1234
1013

output:

1 

result:

ok OK!

Test #11:

score: 0
Accepted
time: 2ms
memory: 3716kb

input:

1 1234 1233
624

output:

impossible

result:

ok OK!

Test #12:

score: -100
Runtime Error

input:

1 1234 0
687

output:


result: