#include <bits/stdc++.h>
#define int long long
#define ll long long
using namespace std;
int dx[8] = {1, 0, -1, 0, -1, 1, -1, 1};
int dy[8] = {0, 1, 0, -1, -1, 1, 1, -1};
int n,d,m;
vector<pair<int,int>>v;
bool can(int md){
int cnt = 0;
int day = 1;
bool ok = 1;
for(int i=0 ; i<m ; i++){
if(day-v[i].first>d){
ok = 0;
break;
}
cnt++;
if(cnt==md)day++,cnt=0;
}
if(!ok)return ok;
return day<=n;
}
void solve() {
cin>>n>>d>>m;
v = vector<pair<int,int>>(m);
for(int i=0 ; i<m ; i++){
cin>>v[i].first;
v[i].second=i+1;
}
std::sort(v.begin(), v.end());
int l =1 , r=1e9;
int best = -1;
while(l<=r){
int md = (l+r)>>1;
if(can(md)){
best = md;
r = md - 1;
}else l = md + 1;
}
int j = 0;
cout<<best<<endl;
for(int i=0 ; i<n ; i++){
for(int w = j ; w<min(j+best,m) ; w++){
cout<<v[w].second<<" ";
}
cout<<0<<endl;
j+=best;
}
}
int32_t main() {
ios_base::sync_with_stdio(false),
cout.tie(nullptr),
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
cout << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
23 ms |
2652 KB |
Output isn't correct |
2 |
Incorrect |
26 ms |
2396 KB |
Output isn't correct |
3 |
Incorrect |
24 ms |
2632 KB |
Output isn't correct |
4 |
Incorrect |
23 ms |
2648 KB |
Output isn't correct |
5 |
Incorrect |
23 ms |
2396 KB |
Output isn't correct |
6 |
Incorrect |
23 ms |
2396 KB |
Output isn't correct |
7 |
Incorrect |
22 ms |
2396 KB |
Output isn't correct |
8 |
Incorrect |
23 ms |
2556 KB |
Output isn't correct |
9 |
Correct |
118 ms |
2640 KB |
Output is correct |
10 |
Correct |
134 ms |
2644 KB |
Output is correct |
11 |
Correct |
20 ms |
2604 KB |
Output is correct |
12 |
Incorrect |
41 ms |
4860 KB |
Output isn't correct |
13 |
Correct |
61 ms |
6996 KB |
Output is correct |
14 |
Incorrect |
97 ms |
9300 KB |
Output isn't correct |
15 |
Incorrect |
105 ms |
11604 KB |
Output isn't correct |
16 |
Correct |
130 ms |
13908 KB |
Output is correct |
17 |
Correct |
171 ms |
16212 KB |
Output is correct |
18 |
Correct |
170 ms |
18352 KB |
Output is correct |
19 |
Correct |
289 ms |
20816 KB |
Output is correct |
20 |
Correct |
155 ms |
16212 KB |
Output is correct |