#include<bits/stdc++.h>
using namespace std;
struct deads
{
int day,work,dead;
bool operator<(const deads&d2)const{
return day<d2.day;
}
};
vector<deads> vc,copys;
int n,d,m,a,l = 1,r = 1e9,ans = 1e9+7;
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){
int mid = (l+r)>>1;
int cnt = 0;
bool ck = 0;
for(int i = 0; i<vc.size(); ++i){
if(vc[i].day==vc[i].dead){
ck = 1;
break;
}
++cnt;
if(cnt==mid){
cnt = 0;
for(int j = i+1; j<vc.size(); ++j){
vc[j].day++;
if(vc[j].day==vc[j].dead){
ck = 1;
break;
}
}
}
if(ck) break;
}
if(ck) l = mid+1;
else r = mid;
vc = copys;
}
int k = m/l+(m%l!=0);
cout<<k<<"\n";
for(int i = 0; i<n; ++i){
cout<<0<<"\n";
}
}
Compilation message
jobs.cpp: In function 'int main()':
jobs.cpp:32:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<deads>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int i = 0; i<vc.size(); ++i){
| ~^~~~~~~~~~
jobs.cpp:40:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<deads>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for(int j = i+1; j<vc.size(); ++j){
| ~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
4016 KB |
Output isn't correct |
2 |
Incorrect |
17 ms |
3896 KB |
Output isn't correct |
3 |
Incorrect |
17 ms |
3852 KB |
Output isn't correct |
4 |
Incorrect |
15 ms |
3976 KB |
Output isn't correct |
5 |
Incorrect |
15 ms |
3900 KB |
Output isn't correct |
6 |
Incorrect |
16 ms |
3912 KB |
Output isn't correct |
7 |
Incorrect |
17 ms |
3912 KB |
Output isn't correct |
8 |
Incorrect |
15 ms |
3912 KB |
Output isn't correct |
9 |
Incorrect |
27 ms |
3812 KB |
Output isn't correct |
10 |
Incorrect |
24 ms |
3864 KB |
Output isn't correct |
11 |
Incorrect |
25 ms |
4152 KB |
Output isn't correct |
12 |
Incorrect |
128 ms |
7584 KB |
Output isn't correct |
13 |
Incorrect |
83 ms |
13436 KB |
Output isn't correct |
14 |
Execution timed out |
1059 ms |
14712 KB |
Time limit exceeded |
15 |
Incorrect |
108 ms |
15788 KB |
Output isn't correct |
16 |
Incorrect |
162 ms |
26132 KB |
Output isn't correct |
17 |
Incorrect |
606 ms |
27392 KB |
Output isn't correct |
18 |
Incorrect |
305 ms |
28500 KB |
Output isn't correct |
19 |
Incorrect |
273 ms |
29704 KB |
Output isn't correct |
20 |
Incorrect |
612 ms |
27232 KB |
Output isn't correct |