#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;
typedef vector<ll> li;
typedef vector<li> lii;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define LSOne(s) ((s)&(-s))
ll INF=1e18+10;
int inf=1e9+10;
ll M=1e9+7;
int main() {
int n,d,m;cin>>n>>d>>m;
vi a(m);
REP(i,0,m)cin>>a[i];
vi b(n+1,0);
REP(i,0,m)b[a[i]+d]++;
int k=0;
int ans=0;cerr<<b[21];
REP(i,1,n+1){
k+=b[i];
int p=k/i;
if(k%i)p++;
int q=b[i]/(d+1);
if(b[i]%d)q++;
ans=max(ans,p);
ans=max(ans,q);
}
cout<<ans<<"\n";
pii arr;
REP(i,0,m)arr.PB({a[i],i+1});
sort(arr.begin(),arr.end());
int pos=0;int x=0;
REP(i,0,n){
while(pos<m&&x<ans){
cout<<arr[pos].S<<" ";
pos++;x++;
}
cout<<"0\n";
x=0;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
2512 KB |
Output is correct |
2 |
Correct |
16 ms |
2512 KB |
Output is correct |
3 |
Correct |
22 ms |
2504 KB |
Output is correct |
4 |
Correct |
16 ms |
2512 KB |
Output is correct |
5 |
Correct |
16 ms |
2512 KB |
Output is correct |
6 |
Correct |
17 ms |
2508 KB |
Output is correct |
7 |
Correct |
18 ms |
2528 KB |
Output is correct |
8 |
Correct |
16 ms |
2508 KB |
Output is correct |
9 |
Correct |
22 ms |
3024 KB |
Output is correct |
10 |
Correct |
23 ms |
3024 KB |
Output is correct |
11 |
Correct |
22 ms |
2544 KB |
Output is correct |
12 |
Correct |
44 ms |
4548 KB |
Output is correct |
13 |
Correct |
67 ms |
7628 KB |
Output is correct |
14 |
Correct |
97 ms |
9144 KB |
Output is correct |
15 |
Incorrect |
112 ms |
11052 KB |
Output isn't correct |
16 |
Correct |
168 ms |
14516 KB |
Output is correct |
17 |
Correct |
211 ms |
16304 KB |
Output is correct |
18 |
Correct |
180 ms |
17328 KB |
Output is correct |
19 |
Correct |
209 ms |
19876 KB |
Output is correct |
20 |
Correct |
170 ms |
15536 KB |
Output is correct |