#include<bits/stdc++.h>
using namespace std;
struct deads
{
int day,work,dead;
bool operator<(const deads&d2)const{
if(day==d2.day) return work>d2.work;
return day<d2.day;
}
};
vector<deads> vc,copys;
int n,d,m,a;
long long l = 1,ans = 1e14,r = 1e14;
int main()
{
ios_base::sync_with_stdio(0),cin.tie(0);
cin>>n>>d>>m;
for(int i = 1; i<=m; ++i){
cin>>a;
vc.push_back({a,i,a+d});
}
sort(vc.begin(), vc.end());
for(auto [day,work,dead]:vc){
copys.push_back({day,work,dead});
}
while(l<r){
long long mid = (l+r)>>1;
long long cnt = 0;
bool ck = 0;
int ps = 0;
for(int i = 0; i<vc.size(); ++i){
if(vc[i].day+ps>=vc[i].dead){
ck = 1;
break;
}
++cnt;
if(cnt==mid){
cnt = 0;
ps++;
}
if(ck) break;
}
if(ck){
ans = min(ans,mid);
l = mid+1;
}
else r = mid;
for(int i = 0; i<copys.size(); ++i){
vc[i] = copys[i];
}
}
int k = ans-1;
cout<<k<<"\n";
int cnt = 0,c = 0;
for(auto [day,work,dead]:vc){
if(cnt==k){
cnt = 0;
++c;
cout<<0<<"\n";
}
++cnt;
cout<<work<<" ";
}
if(c!=m) cout<<"0\n";
for(int i = 0; i<n-c-1; ++i) cout<<0<<"\n";
}
Compilation message
jobs.cpp: In function 'int main()':
jobs.cpp:35:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<deads>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for(int i = 0; i<vc.size(); ++i){
| ~^~~~~~~~~~
jobs.cpp:52:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<deads>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for(int i = 0; i<copys.size(); ++i){
| ~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
4068 KB |
Output isn't correct |
2 |
Incorrect |
42 ms |
4108 KB |
Output isn't correct |
3 |
Incorrect |
41 ms |
4108 KB |
Output isn't correct |
4 |
Incorrect |
43 ms |
4048 KB |
Output isn't correct |
5 |
Incorrect |
33 ms |
4040 KB |
Output isn't correct |
6 |
Incorrect |
46 ms |
4040 KB |
Output isn't correct |
7 |
Incorrect |
33 ms |
4096 KB |
Output isn't correct |
8 |
Incorrect |
35 ms |
4032 KB |
Output isn't correct |
9 |
Incorrect |
59 ms |
4012 KB |
Output isn't correct |
10 |
Incorrect |
56 ms |
4032 KB |
Output isn't correct |
11 |
Incorrect |
52 ms |
4136 KB |
Output isn't correct |
12 |
Incorrect |
91 ms |
8004 KB |
Output isn't correct |
13 |
Incorrect |
152 ms |
13948 KB |
Output isn't correct |
14 |
Incorrect |
220 ms |
15796 KB |
Output isn't correct |
15 |
Incorrect |
282 ms |
17028 KB |
Output isn't correct |
16 |
Incorrect |
324 ms |
28136 KB |
Output isn't correct |
17 |
Incorrect |
356 ms |
29760 KB |
Output isn't correct |
18 |
Incorrect |
397 ms |
30676 KB |
Output isn't correct |
19 |
Incorrect |
438 ms |
32132 KB |
Output isn't correct |
20 |
Incorrect |
353 ms |
29716 KB |
Output isn't correct |