#include <bits/stdc++.h>
#define f0(i, n) for(int i(0); i < (n); i++)
#define f1(i, n) for(int i(1); i <= n; i++)
using namespace std;
typedef long long ll;
const int N = 100002;
int n, d, m;
pair <int, int> a[N];
vector <vector <int> > v, b;
bool check(int x){
f1(i, n) v[i].clear();
int ma = n - d, cur = 0;
f1(i, m){
cur++;
if(cur <= x){
v[ma].emplace_back(a[i].second);
}
else{
cur = 1;
ma--;
if(ma==0) return 0;
v[ma].emplace_back(a[i].second);
}
}
return 1;
}
int main(){
ios_base::sync_with_stdio(0);
cin >> n >> d >> m;
v.resize(n + 1);
b.resize(n + 1);
f1(i, m){
int x; cin >> x;
a[i] = {x, i};
}
sort(a + 1, a + m + 1);
int l = 1, r = n, ans = n;
while(l <= r){
int mid = (l + r)/2;
if(check(mid)){
r = mid - 1, ans = mid;
f1(i, n){
b[i].clear();
for(auto x:v[i]){
b[i].emplace_back(x);
}
}
}
else l = mid + 1;
}
cout << ans << endl;
f1(i, n){
for(auto x:b[i]) cout << x << " ";
cout << 0 << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
101 ms |
9584 KB |
Output isn't correct |
2 |
Incorrect |
74 ms |
9944 KB |
Output isn't correct |
3 |
Incorrect |
63 ms |
10216 KB |
Output isn't correct |
4 |
Incorrect |
58 ms |
10576 KB |
Output isn't correct |
5 |
Incorrect |
60 ms |
10964 KB |
Output isn't correct |
6 |
Incorrect |
57 ms |
11268 KB |
Output isn't correct |
7 |
Incorrect |
57 ms |
11564 KB |
Output isn't correct |
8 |
Incorrect |
57 ms |
11924 KB |
Output isn't correct |
9 |
Incorrect |
235 ms |
21064 KB |
Output isn't correct |
10 |
Incorrect |
255 ms |
21308 KB |
Output isn't correct |
11 |
Incorrect |
40 ms |
21308 KB |
Output isn't correct |
12 |
Runtime error |
13 ms |
21308 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Runtime error |
13 ms |
21308 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
14 |
Runtime error |
16 ms |
21308 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
15 |
Runtime error |
13 ms |
21308 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
16 |
Runtime error |
15 ms |
21308 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
17 |
Runtime error |
15 ms |
21308 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Runtime error |
14 ms |
21308 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Runtime error |
182 ms |
21308 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Runtime error |
16 ms |
21308 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |