#include <bits/stdc++.h>
#define ll long long
#define FOR(x, n) for(int x = 0; x < n; x++)
#define LFOR(x, l, r) for(int x = l; x < r; x++)
#define last(x) x[x.size()-1]
#define negind(x, i) x[x.size()-i]
#define pii pair<int, int>
#define ins insert
#define pb push_back
#define pf push_front
#define s(x) set(x)
#define v(x) vector<x>
#define uom(x, y) unordered_map<x, y>
#define triplet(x) tuple<x, x, x>
#define all(x) x.begin(), x.end()
#define inf INT_MAX
using namespace std;
inline void solve(){
int N, D, M;
cin >> N >> D >> M;
pii a[M];
FOR(i, M){
cin >> a[i].first;
a[i].second = i+1;
}
sort(a, a+M);
int l = 1, r = 1000000, sol;
while(l <= r){
int mid = l + (r-l)/2, index = mid-1, day = 1, delay = 0;
while(index < M){
delay = max(delay, day-a[index].first);
day++;
FOR(i, mid){
if(index >= M || a[index+1].first > day) break;
index++;
}
}
if(delay <= D) sol = mid, r = mid - 1;
else l = mid+1;
}
cout << sol << "\n";
int index = 0;
while(index < M){
LFOR(i, index, min(M, index+sol)) cout << a[i].second << " ";
index += sol;
cout << "0\n";
}
FOR(i, N-ceil((double)M/sol)) cout << "0\n";
}
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
solve();
return 0;
}
Compilation message
jobs.cpp: In function 'void solve()':
jobs.cpp:50:15: warning: 'sol' may be used uninitialized in this function [-Wmaybe-uninitialized]
50 | FOR(i, N-ceil((double)M/sol)) cout << "0\n";
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
106 ms |
1588 KB |
Output isn't correct |
2 |
Incorrect |
117 ms |
1596 KB |
Output isn't correct |
3 |
Incorrect |
96 ms |
1604 KB |
Output isn't correct |
4 |
Incorrect |
100 ms |
1588 KB |
Output isn't correct |
5 |
Incorrect |
98 ms |
1600 KB |
Output isn't correct |
6 |
Incorrect |
102 ms |
1584 KB |
Output isn't correct |
7 |
Incorrect |
109 ms |
1592 KB |
Output isn't correct |
8 |
Incorrect |
97 ms |
1604 KB |
Output isn't correct |
9 |
Incorrect |
105 ms |
1868 KB |
Output isn't correct |
10 |
Incorrect |
105 ms |
1848 KB |
Output isn't correct |
11 |
Incorrect |
103 ms |
1568 KB |
Output isn't correct |
12 |
Incorrect |
144 ms |
3044 KB |
Output isn't correct |
13 |
Incorrect |
150 ms |
4556 KB |
Output isn't correct |
14 |
Incorrect |
176 ms |
6116 KB |
Output isn't correct |
15 |
Incorrect |
131 ms |
7700 KB |
Output isn't correct |
16 |
Incorrect |
228 ms |
9084 KB |
Output isn't correct |
17 |
Incorrect |
262 ms |
10520 KB |
Output isn't correct |
18 |
Incorrect |
276 ms |
12076 KB |
Output isn't correct |
19 |
Incorrect |
308 ms |
13756 KB |
Output isn't correct |
20 |
Incorrect |
257 ms |
10512 KB |
Output isn't correct |