#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()
int n, k, t, a, lo, hi=1000000, mid;
vector<int> v[100005];
bool f;
queue<pii> q;
bool check(int L){
while(!q.empty()) q.pop();
fox1(l, n){
fox(l2, v[l].size()) q.push(mp(l, v[l][l2]));
for(int l2=0; l2<L && q.size(); ++l2){
if (l-q.front().x>k) return 0;
if (f)
printf("%i ", q.front().y+1);
q.pop();
}
if (f)
printf("0\n");
}
return 1;
}
int main(){
scanf("%i%i%i", &n, &k, &t);
fox(l, t){
scanf("%i", &a);
v[a].pb(l);
}
while(lo<hi){
mid=(lo+hi)/2;
if (check(mid)) hi=mid;
else lo=mid+1;
}
f=1;
printf("%i\n", lo);
check(lo);
return 0;
}
Compilation message
jobs.cpp: In function 'bool check(int)':
jobs.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
^
jobs.cpp:34:9: note: in expansion of macro 'fox'
fox(l2, v[l].size()) q.push(mp(l, v[l][l2]));
^
jobs.cpp: In function 'int main()':
jobs.cpp:47:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i%i%i", &n, &k, &t);
^
jobs.cpp:49:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i", &a);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
43 ms |
5748 KB |
Output is correct |
2 |
Correct |
36 ms |
5748 KB |
Output is correct |
3 |
Correct |
39 ms |
5748 KB |
Output is correct |
4 |
Correct |
33 ms |
5748 KB |
Output is correct |
5 |
Correct |
39 ms |
5748 KB |
Output is correct |
6 |
Correct |
46 ms |
5748 KB |
Output is correct |
7 |
Correct |
43 ms |
5748 KB |
Output is correct |
8 |
Correct |
36 ms |
5748 KB |
Output is correct |
9 |
Correct |
49 ms |
5080 KB |
Output is correct |
10 |
Correct |
49 ms |
5204 KB |
Output is correct |
11 |
Correct |
39 ms |
4892 KB |
Output is correct |
12 |
Correct |
99 ms |
5552 KB |
Output is correct |
13 |
Correct |
119 ms |
6608 KB |
Output is correct |
14 |
Correct |
219 ms |
7408 KB |
Output is correct |
15 |
Correct |
219 ms |
7400 KB |
Output is correct |
16 |
Correct |
346 ms |
8324 KB |
Output is correct |
17 |
Correct |
393 ms |
9644 KB |
Output is correct |
18 |
Correct |
319 ms |
8720 KB |
Output is correct |
19 |
Correct |
369 ms |
8720 KB |
Output is correct |
20 |
Correct |
393 ms |
9644 KB |
Output is correct |