#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ifstream in("input.txt");
ofstream out("output.txt");
typedef long long ll;
int n,d,m;
pair<int,int> v[1000001];
bool funz(int k){
if(k>n)return 0;
int p=1;
for(int i=0;i<m;i+=k){
for(int y=i;y<i+k;y++){
if(p>v[y].fi+d)return 0;
}
p++;
}
return 1;
}
int main(){
cin>>n>>d>>m;
for(int i=0;i<m;i++){
cin>>v[i].fi;
v[i].se=i;
}
sort(v,v+m);
int s=1;
int d=m;
int minn=1e9;
while(s<=d){
int k=(s+d)/2;
if(funz(k)){
minn=min(minn,k);
d=k-1;
}
else{
s=k+1;
}
}
cout<<minn<<endl;
for(int i=0;i<m;i+=minn){
for(int y=i;y<i+minn&&y<m;y++){
cout<<v[y].se+1<<" ";
}
cout<<"0 "<<endl;
}
for(int i=m/minn+min(1,m%minn);i<n;i++){
cout<<"0 "<<endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
73 ms |
1896 KB |
Output isn't correct |
2 |
Incorrect |
73 ms |
1784 KB |
Output isn't correct |
3 |
Incorrect |
72 ms |
1784 KB |
Output isn't correct |
4 |
Incorrect |
73 ms |
1896 KB |
Output isn't correct |
5 |
Incorrect |
72 ms |
1784 KB |
Output isn't correct |
6 |
Incorrect |
72 ms |
1908 KB |
Output isn't correct |
7 |
Incorrect |
73 ms |
2040 KB |
Output isn't correct |
8 |
Incorrect |
74 ms |
1912 KB |
Output isn't correct |
9 |
Incorrect |
314 ms |
2040 KB |
Output isn't correct |
10 |
Incorrect |
314 ms |
2020 KB |
Output isn't correct |
11 |
Incorrect |
62 ms |
1784 KB |
Output isn't correct |
12 |
Incorrect |
121 ms |
3192 KB |
Output isn't correct |
13 |
Incorrect |
183 ms |
4596 KB |
Output isn't correct |
14 |
Incorrect |
296 ms |
6268 KB |
Output isn't correct |
15 |
Incorrect |
314 ms |
7672 KB |
Output isn't correct |
16 |
Incorrect |
449 ms |
9204 KB |
Output isn't correct |
17 |
Incorrect |
498 ms |
10704 KB |
Output isn't correct |
18 |
Incorrect |
518 ms |
12380 KB |
Output isn't correct |
19 |
Incorrect |
801 ms |
14200 KB |
Output isn't correct |
20 |
Incorrect |
505 ms |
10844 KB |
Output isn't correct |