#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll,ll>;
#define el cout << '\n'
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FOD(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
template <class T1, class T2>void chmax(T1 &a, T2 b){a = max(a, b);}
template <class T1, class T2>void chmin(T1 &a, T2 b){a = min(a, b);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 2e5 + 5;
const ll mod = 998244353;
int n, d, m;
pair<bool, vector<vector<int>>> check (int mid, vector<pii> x){
int cur = 0;
vector<vector<int>> ans(n + 1);
for (int day = 1; day <= n; day++){
for (int j = 0; j < mid; j++){
if (x[cur].fi > day) break;
if (x[cur].fi + d < day) return {false, ans};
ans[day].pb(x[cur].se);
cur++;
if (cur == m) return {true, ans};
}
}
return {false, ans};
}
void solve(){
cin >> n >> d >> m;
vector<pii> x(m);
REP(i, m){
cin >> x[i].fi;
x[i].se = i + 1;
}
sort(all(x));
vector<vector<int>> ans;
int l = 0, r = m + 1;
while(r - l > 1){
int m = (l + r) / 2;
auto [res1, res2] = check(m, x);
if (res1) r = m, ans = res2;
else l = m;
}
cout << r << '\n';
FOR(i, 1, n){
for (auto v : ans[i]) cout << v << " ";
cout << 0 << '\n';
}
}
int32_t main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("debug.txt", "w", stderr);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tests = 1;
//cin >> tests;
for (int itest = 1; itest <= tests; itest++){
cerr << "- TEST " << itest << ": \n";
solve();
el;
}
return 0;
}
Compilation message
jobs.cpp: In function 'int32_t main()':
jobs.cpp:68:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
68 | freopen("input.txt", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:69:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
69 | freopen("output.txt", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:70:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
70 | freopen("debug.txt", "w", stderr);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
1 ms |
348 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
2 ms |
344 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
2 ms |
348 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
2 ms |
348 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
1 ms |
528 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
2 ms |
344 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
2 ms |
348 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
2 ms |
348 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
1 ms |
348 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
3 ms |
348 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
2 ms |
348 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
1 ms |
348 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
2 ms |
348 KB |
Unexpected end of file - int32 expected |
15 |
Incorrect |
2 ms |
348 KB |
Unexpected end of file - int32 expected |
16 |
Incorrect |
2 ms |
348 KB |
Unexpected end of file - int32 expected |
17 |
Incorrect |
2 ms |
344 KB |
Unexpected end of file - int32 expected |
18 |
Incorrect |
2 ms |
348 KB |
Unexpected end of file - int32 expected |
19 |
Incorrect |
2 ms |
348 KB |
Unexpected end of file - int32 expected |
20 |
Incorrect |
2 ms |
348 KB |
Unexpected end of file - int32 expected |