#include <bits/stdc++.h>
using namespace std;
long long n,d,m;
vector<long long> v;
long long freq[100002];
bool moze(long long k)
{
long long rabota = 0;
for (long long i=1;i<=n;i++)
{
rabota += freq[i];
long long potrebni_denovi = rabota/k;
if (rabota%k>0) potrebni_denovi++;
if (potrebni_denovi>d+1) return false;
rabota-=k;
if (rabota<0) rabota = 0;
}
if (rabota<=0) return true;
return false;
}
long long bs(long long l,long long r)
{
if (l==r) return l;
long long mid = (l+r)/2;
if (moze(mid)) return bs(l,mid);
else return bs(mid+1,r);
}
void pecati(long long k)
{
vector<pair<long long,long long> > q;
for (long long i=0;i<v.size();i++) q.push_back({v[i],i+1});
sort(q.begin(),q.end());
long long den=1,koristeni=0;
for (long long i=0;i<q.size();i++)
{
if (koristeni==k)
{
koristeni=0;
den++;
cout<<0<<endl;
}
long long 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 (long long i=0;i<m;i++)
{
long long a;
cin>>a;
freq[a]++;
v.push_back(a);
}
long long kec = 1;
long long odg = bs(kec,m);
cout<<odg<<endl;
//pecati(odg);
return 0;
}
Compilation message
jobs.cpp: In function 'void pecati(long long int)':
jobs.cpp:35:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for (long long i=0;i<v.size();i++) q.push_back({v[i],i+1});
| ~^~~~~~~~~
jobs.cpp:38:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for (long long i=0;i<q.size();i++)
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1500 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
4 ms |
1500 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
5 ms |
1500 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
6 ms |
1752 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
8 ms |
1500 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
5 ms |
1500 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
5 ms |
1500 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
4 ms |
1500 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
7 ms |
1500 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
7 ms |
1500 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
5 ms |
1500 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
10 ms |
2520 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
26 ms |
4560 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
23 ms |
4564 KB |
Unexpected end of file - int32 expected |
15 |
Incorrect |
23 ms |
4560 KB |
Unexpected end of file - int32 expected |
16 |
Incorrect |
54 ms |
8684 KB |
Unexpected end of file - int32 expected |
17 |
Incorrect |
35 ms |
8656 KB |
Unexpected end of file - int32 expected |
18 |
Incorrect |
42 ms |
8644 KB |
Unexpected end of file - int32 expected |
19 |
Incorrect |
71 ms |
8572 KB |
Unexpected end of file - int32 expected |
20 |
Incorrect |
39 ms |
8860 KB |
Unexpected end of file - int32 expected |