#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector,Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll N=2e5+5;
const ll MOD=1e9+7;
const ld pi=acos(-1);
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()
ll n,st[N],d,m;
vector<ll> done[N],upd[N];
queue<ll> que;
bool ck(ll k){
while(SZ(que))que.pop();
REP1(i,n){
done[i].clear();
for(ll j:upd[i])que.push(j);
REP(j,k){
if(!SZ(que))break;
done[i].pb(que.front());
que.pop();
}
if(SZ(que)&&st[que.front()]+d<=i)return 0;
}
return 1;
}
void out(ll id){
for(auto i:done[id])cout<<i<<" ";
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>d>>m;
REP1(i,m){
cin>>st[i];
upd[st[i]].pb(i);
}
ll r=n,l=-1;
while(l<r-1){
ll mid=(l+r)>>1;
if(ck(mid)){
r=mid;
}else{
l=mid;
}
}
cout<<r<<"\n";
REP1(i,n){
for(auto j:done[i])cout<<j<<" ";
cout<<"0\n";
}
return 0;
}
/*
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
25 ms |
12904 KB |
Output isn't correct |
2 |
Incorrect |
24 ms |
12904 KB |
Output isn't correct |
3 |
Incorrect |
25 ms |
12904 KB |
Output isn't correct |
4 |
Incorrect |
25 ms |
12904 KB |
Output isn't correct |
5 |
Incorrect |
25 ms |
12904 KB |
Output isn't correct |
6 |
Incorrect |
24 ms |
12904 KB |
Output isn't correct |
7 |
Incorrect |
25 ms |
12904 KB |
Output isn't correct |
8 |
Incorrect |
25 ms |
12904 KB |
Output isn't correct |
9 |
Correct |
44 ms |
13676 KB |
Output is correct |
10 |
Correct |
43 ms |
13804 KB |
Output is correct |
11 |
Correct |
33 ms |
13676 KB |
Output is correct |
12 |
Correct |
58 ms |
17516 KB |
Output is correct |
13 |
Runtime error |
45 ms |
28268 KB |
Execution killed with signal 11 |
14 |
Runtime error |
51 ms |
29036 KB |
Execution killed with signal 11 |
15 |
Runtime error |
43 ms |
28012 KB |
Execution killed with signal 11 |
16 |
Runtime error |
51 ms |
28780 KB |
Execution killed with signal 11 |
17 |
Runtime error |
52 ms |
29420 KB |
Execution killed with signal 11 |
18 |
Runtime error |
44 ms |
28268 KB |
Execution killed with signal 11 |
19 |
Runtime error |
44 ms |
28268 KB |
Execution killed with signal 11 |
20 |
Runtime error |
52 ms |
29292 KB |
Execution killed with signal 11 |