#include <bits/stdc++.h>
#define fr first
#define se second
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define repr(i,a,b) for(int i = a; i > (b); --i)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define IN(i,l,r) (l<i&&i<r)
#define pb push_back
using namespace std;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef long long ll;
const int U = 1e6+2;
int N,D,M;
pi job[U];
int jd[U/10 + 1];
bool check(int m){
int day = 0,t = 0;
while(day < N && t < M){
++day;
if(job[t].fr + D < day){
return false;
}
t = min(t+m,jd[day]);
if(job[t-1].fr + D < day){
return false;
}
}
return true;
}
int main(){
cin.tie(0)->sync_with_stdio(false);
cin >> N >> D >> M;
rep(i,0,M){
cin >> job[i].fr;
jd[job[i].fr] += 1;
job[i].se = i+1;
}
rep(i,2,N+1) jd[i] += jd[i-1];
sort(job,job+M);
int lo=1,hi=M;
while(lo < hi){
ll m = (lo+hi)/2;
if(check(m)){
hi = m;
}else{
lo = m+1;
}
}
if(!check(hi)) hi += 1;
cout << hi << '\n';
int day = 0,t = 0;
while(day < N){
++day;
int t_ = min(t+hi,jd[day]);
rep(i,t,t_){
cout << job[i].se << ' ';
}
cout << "0\n";
t = t_;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
11 ms |
3164 KB |
Output isn't correct |
2 |
Incorrect |
12 ms |
3160 KB |
Output isn't correct |
3 |
Incorrect |
11 ms |
3164 KB |
Output isn't correct |
4 |
Incorrect |
11 ms |
3064 KB |
Output isn't correct |
5 |
Incorrect |
11 ms |
3164 KB |
Output isn't correct |
6 |
Incorrect |
11 ms |
3164 KB |
Output isn't correct |
7 |
Incorrect |
11 ms |
3164 KB |
Output isn't correct |
8 |
Incorrect |
11 ms |
2956 KB |
Output isn't correct |
9 |
Correct |
20 ms |
3412 KB |
Output is correct |
10 |
Correct |
20 ms |
3416 KB |
Output is correct |
11 |
Correct |
19 ms |
2908 KB |
Output is correct |
12 |
Correct |
37 ms |
3664 KB |
Output is correct |
13 |
Correct |
56 ms |
6352 KB |
Output is correct |
14 |
Correct |
78 ms |
7248 KB |
Output is correct |
15 |
Correct |
93 ms |
10096 KB |
Output is correct |
16 |
Correct |
117 ms |
10576 KB |
Output is correct |
17 |
Correct |
137 ms |
11240 KB |
Output is correct |
18 |
Correct |
153 ms |
12492 KB |
Output is correct |
19 |
Correct |
175 ms |
14280 KB |
Output is correct |
20 |
Correct |
137 ms |
11344 KB |
Output is correct |