#include <bits/stdc++.h>
using namespace std;
int n,d,m;
vector<int> v;
int freq[100001];
bool moze(int k)
{
int utre=0;
for (int den=1;den<=n;den++)
{
int rabota_denes = freq[den] + utre;
int potrebno = rabota_denes/k;
if (rabota_denes%k>0) potrebno++;
if (potrebno-1>d) return false;
utre = rabota_denes-k;
}
return true;
}
int bs(int l,int r)
{
if (l==r) return l;
int mid = (l+r)/2;
if (moze(mid)) return bs(l,mid);
else return bs(mid+1,r);
}
void pecati(int k)
{
vector<pair<int,int> > q;
for (int i=0;i<v.size();i++) q.push_back({v[i],i+1});
sort(q.begin(),q.end());
int den=1,koristeni=0;
for (int i=0;i<q.size();i++)
{
if (koristeni==k)
{
koristeni=0;
den++;
cout<<0<<endl;
}
int x = q[i].first,it=q[i].second;
if (den<x)
{
while(den<x)
{
den++;
cout<<0<<endl;
}
}
koristeni++;
cout<<it<<" ";
}
while(den<=n)
{
cout<<0<<endl;
den++;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>d>>m;
for (int i=0;i<m;i++)
{
int a;
cin>>a;
freq[a]++;
v.push_back(a);
}
int odg = bs(1,m);
cout<<odg<<endl;
pecati(odg);
return 0;
}
Compilation message
jobs.cpp: In function 'void pecati(int)':
jobs.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for (int i=0;i<v.size();i++) q.push_back({v[i],i+1});
| ~^~~~~~~~~
jobs.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for (int i=0;i<q.size();i++)
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
29 ms |
2668 KB |
Output isn't correct |
2 |
Incorrect |
23 ms |
2652 KB |
Output isn't correct |
3 |
Incorrect |
26 ms |
2684 KB |
Output isn't correct |
4 |
Incorrect |
25 ms |
2652 KB |
Output isn't correct |
5 |
Incorrect |
23 ms |
2652 KB |
Output isn't correct |
6 |
Incorrect |
23 ms |
2652 KB |
Output isn't correct |
7 |
Incorrect |
23 ms |
2488 KB |
Output isn't correct |
8 |
Incorrect |
29 ms |
2600 KB |
Output isn't correct |
9 |
Incorrect |
126 ms |
2636 KB |
Output isn't correct |
10 |
Incorrect |
154 ms |
2640 KB |
Output isn't correct |
11 |
Correct |
21 ms |
2652 KB |
Output is correct |
12 |
Correct |
43 ms |
4796 KB |
Output is correct |
13 |
Correct |
60 ms |
6796 KB |
Output is correct |
14 |
Correct |
102 ms |
9768 KB |
Output is correct |
15 |
Incorrect |
118 ms |
11076 KB |
Output isn't correct |
16 |
Incorrect |
138 ms |
14232 KB |
Output isn't correct |
17 |
Incorrect |
159 ms |
16656 KB |
Output isn't correct |
18 |
Incorrect |
172 ms |
17508 KB |
Output isn't correct |
19 |
Incorrect |
295 ms |
19412 KB |
Output isn't correct |
20 |
Incorrect |
157 ms |
15672 KB |
Output isn't correct |