#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
using pii = pair<ll , ll> ;
using i3 = tuple<ll , ll , ll> ;
const int N = 1e5+5 ;
const int MOD = 1e9+7 ;
ll n , d , m ;
pii S[N] ;
vector<ll> ans2[N] ;
bool solve(ll mid){
ll day = 1 , cnt = 0 ;
for(int i=1;i<=m;i++){
if(day <= S[i].first){ // do job i-th
cnt++ ;
ans2[day].push_back(S[i].second) ;
}
else {
return false ;
}
if(cnt == mid){
day++;
cnt = 0 ;
}
}
if(cnt == 0) day--;
return day <= n ;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> d >> m ;
for(int i=1, x;i<=m;i++){
cin >> x ;
S[i] = {x + d , i};
}
sort(S+1 , S+m+1) ;
ll l = 1 , r = m , ans ;
while(l <= r){
ll mid = (l+r)/2 ;
if(solve(mid)){
r = mid-1 ;
ans = mid ;
}
else {
l = mid+1 ;
for(int i=1;i<=n;i++) ans2[i].clear();
}
}
cout << ans << "\n" ;
for(int i=1;i<=n;i++){
for(int x : ans2[i]){
cout << x << " " ;
}
cout << "0\n" ;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
11052 KB |
Output isn't correct |
2 |
Incorrect |
19 ms |
11036 KB |
Output isn't correct |
3 |
Incorrect |
27 ms |
12376 KB |
Output isn't correct |
4 |
Incorrect |
19 ms |
11196 KB |
Output isn't correct |
5 |
Incorrect |
20 ms |
12716 KB |
Output isn't correct |
6 |
Incorrect |
20 ms |
12496 KB |
Output isn't correct |
7 |
Incorrect |
40 ms |
12708 KB |
Output isn't correct |
8 |
Incorrect |
25 ms |
11700 KB |
Output isn't correct |
9 |
Correct |
27 ms |
11000 KB |
Output is correct |
10 |
Correct |
27 ms |
11008 KB |
Output is correct |
11 |
Correct |
36 ms |
17664 KB |
Output is correct |
12 |
Runtime error |
15 ms |
8916 KB |
Execution killed with signal 11 |
13 |
Runtime error |
51 ms |
31628 KB |
Execution killed with signal 11 |
14 |
Runtime error |
12 ms |
8916 KB |
Execution killed with signal 11 |
15 |
Runtime error |
12 ms |
8960 KB |
Execution killed with signal 11 |
16 |
Runtime error |
13 ms |
8992 KB |
Execution killed with signal 11 |
17 |
Runtime error |
13 ms |
8916 KB |
Execution killed with signal 11 |
18 |
Runtime error |
16 ms |
8852 KB |
Execution killed with signal 11 |
19 |
Runtime error |
14 ms |
8928 KB |
Execution killed with signal 11 |
20 |
Runtime error |
14 ms |
9004 KB |
Execution killed with signal 11 |