// In the name of God
// Hope is last to die
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb push_back
#define S second
#define F first
#define mp make_pair
#define smax(x, y) (x) = max((x), (y))
#define smin(x, y) (x) = min((x), (y))
#define all(x) (x).begin(), (x).end()
#define len(x) ((int)(x).size())
const int maxn = 1e5 + 5, maxm = 1e6 + 5;
const int inf = 1e9 + 7;
int n, d, m;
pii a[maxm];
vector<int> vec[maxn];
bool check(int k){
int cur = 0;
for(int i = 1; i <= n; i++){
vec[i].clear();
int cnt = 0;
while(cnt < k && cur < m && a[cur].F <= i && a[cur].F + d <= i){
vec[i].pb(a[cur].S);
cnt++;
cur++;
}
}
if(cur != m) return 0;
return 1;
}
int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> d >> m;
for(int i = 0; i < m; i++){
cin >> a[i].F;
a[i].S = i + 1;
}
sort(a, a + m);
int l = 0, r = m + 1;
while(r - l > 1){
int mid = (l + r) / 2;
if(check(mid)) r = mid;
else l = mid;
}
cout << l + 1 << '\n';
check(l + 1);
for(int i = 1; i <= n; i++){
for(auto u: vec[i]) cout << u << ' ';
cout << 0 << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
9040 KB |
Output isn't correct |
2 |
Incorrect |
18 ms |
9052 KB |
Output isn't correct |
3 |
Incorrect |
20 ms |
9040 KB |
Output isn't correct |
4 |
Incorrect |
18 ms |
9048 KB |
Output isn't correct |
5 |
Incorrect |
19 ms |
9052 KB |
Output isn't correct |
6 |
Incorrect |
19 ms |
9052 KB |
Output isn't correct |
7 |
Incorrect |
18 ms |
9052 KB |
Output isn't correct |
8 |
Incorrect |
19 ms |
8960 KB |
Output isn't correct |
9 |
Incorrect |
38 ms |
11176 KB |
Output isn't correct |
10 |
Incorrect |
40 ms |
11344 KB |
Output isn't correct |
11 |
Incorrect |
22 ms |
5724 KB |
Output isn't correct |
12 |
Incorrect |
46 ms |
6784 KB |
Output isn't correct |
13 |
Incorrect |
73 ms |
10624 KB |
Output isn't correct |
14 |
Incorrect |
97 ms |
11892 KB |
Output isn't correct |
15 |
Incorrect |
113 ms |
13164 KB |
Output isn't correct |
16 |
Incorrect |
143 ms |
16208 KB |
Output isn't correct |
17 |
Incorrect |
191 ms |
18512 KB |
Output isn't correct |
18 |
Incorrect |
203 ms |
25724 KB |
Output isn't correct |
19 |
Runtime error |
245 ms |
36548 KB |
Memory limit exceeded |
20 |
Incorrect |
178 ms |
18556 KB |
Output isn't correct |