#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;z
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long long
//#define ordst tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag , tree_order_statistics_node_update >
//#define double long double
//template <class F, class _S>
//bool chmin(F &u, const _S &v){
//bool flag = false;
//if ( u > v ){
//u = v; flag |= true;
//}
//return flag;
//}
//template <class F, class _S>
//bool chmax(F &u, const _S &v){
//bool flag = false;
//if ( u < v ){
//u = v; flag |= true;
//}
//return flag;
//}
//const int N = (1<<18) +1, inf = 1e18+200;
//int mod = 998244353;
//int mod = 1000000007;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define rnd(l, r) uniform_int_distribution <int> (l, r)(rng)
void solve(){
int n, d, m;
cin >> n >> d >> m;
vector<array<int,2>> v(m);
int ii = 1;
for(auto &[f, s]:v){cin >> f; s = ii++;}
sort(all(v));
auto ok = [&](int x) -> bool{
int cnt = x, day = 1, it = 0;
while(day <= n){
cnt = x;
while(cnt-- && it < m && v[it][0] <= day){
if(v[it][0]+d < day)return false;
it++;
}
day++;
}
return it == m;
};
int l = 1, r = 1e15;
while(l < r){
int md = (l+r)>>1;
//cout << md << '\n';
if(ok(md)){
r = md;
}else l = md+1;
}
cout << l << '\n';
int cnt = l, day = 1, it = 0;
while(day <= n){
cnt = l;
while(cnt-- && it < m && v[it][0] <= day){
cout << v[it][1] << ' ';
it++;
}
day++;
cout << 0 << '\n';
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int tt = 1;
//cin >> tt;
while(tt--){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
2392 KB |
Output is correct |
2 |
Correct |
17 ms |
2396 KB |
Output is correct |
3 |
Correct |
17 ms |
2396 KB |
Output is correct |
4 |
Correct |
17 ms |
2396 KB |
Output is correct |
5 |
Correct |
17 ms |
2648 KB |
Output is correct |
6 |
Correct |
16 ms |
2396 KB |
Output is correct |
7 |
Correct |
17 ms |
2552 KB |
Output is correct |
8 |
Correct |
17 ms |
2652 KB |
Output is correct |
9 |
Correct |
31 ms |
2652 KB |
Output is correct |
10 |
Correct |
30 ms |
2644 KB |
Output is correct |
11 |
Correct |
23 ms |
2384 KB |
Output is correct |
12 |
Correct |
50 ms |
4692 KB |
Output is correct |
13 |
Correct |
77 ms |
6992 KB |
Output is correct |
14 |
Correct |
99 ms |
9348 KB |
Output is correct |
15 |
Correct |
120 ms |
11600 KB |
Output is correct |
16 |
Correct |
150 ms |
13940 KB |
Output is correct |
17 |
Correct |
170 ms |
16208 KB |
Output is correct |
18 |
Correct |
204 ms |
18256 KB |
Output is correct |
19 |
Correct |
225 ms |
20952 KB |
Output is correct |
20 |
Correct |
182 ms |
16212 KB |
Output is correct |