#include<bits/stdc++.h>
using namespace std;
vector<tuple<int, int, int>> 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;
bool ck = 0;
int cnt = 0;
for(int i = 0; i<copys.size(); ++i){
bool s = 0;
auto &[day,work,dead] = vc[i];
if(day==dead){
ck = 1;
break;
}
++cnt;
if(cnt==mid){
cnt = 0;
for(int j = i+1; j<copys.size(); ++j){
auto &[day,work,dead] = vc[j];
day++;
}
}
if(s){
ck = 1;
break;
}
}
if(ck){
l = mid+1;
}
else{
r = mid;
}
//vc = copys;
}
cout<<l+1<<"\n";
int cnt = 0,c = 0;
for(auto [day,work,dead]:copys){
if(cnt==l+1){
cout<<0;
cnt = 0;
++c;
cout<<"\n";
}
cout<<work<<" ";
++cnt;
}
++c;
cout<<"0\n";
for(int i = 0; i<n-c; ++i){
cout<<0<<"\n";
}
}
Compilation message
jobs.cpp: In function 'int main()':
jobs.cpp:24:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(int i = 0; i<copys.size(); ++i){
| ~^~~~~~~~~~~~~
jobs.cpp:34:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | for(int j = i+1; j<copys.size(); ++j){
| ~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
26 ms |
3784 KB |
Output isn't correct |
2 |
Incorrect |
20 ms |
3784 KB |
Output isn't correct |
3 |
Incorrect |
21 ms |
3784 KB |
Output isn't correct |
4 |
Incorrect |
20 ms |
3696 KB |
Output isn't correct |
5 |
Incorrect |
23 ms |
3744 KB |
Output isn't correct |
6 |
Incorrect |
21 ms |
3784 KB |
Output isn't correct |
7 |
Incorrect |
20 ms |
3820 KB |
Output isn't correct |
8 |
Incorrect |
20 ms |
3784 KB |
Output isn't correct |
9 |
Incorrect |
36 ms |
3816 KB |
Output isn't correct |
10 |
Incorrect |
33 ms |
3784 KB |
Output isn't correct |
11 |
Incorrect |
27 ms |
3784 KB |
Output isn't correct |
12 |
Incorrect |
83 ms |
7272 KB |
Output isn't correct |
13 |
Incorrect |
89 ms |
13068 KB |
Output isn't correct |
14 |
Incorrect |
537 ms |
14228 KB |
Output isn't correct |
15 |
Incorrect |
147 ms |
15504 KB |
Output isn't correct |
16 |
Incorrect |
182 ms |
25748 KB |
Output isn't correct |
17 |
Incorrect |
333 ms |
26908 KB |
Output isn't correct |
18 |
Incorrect |
244 ms |
28180 KB |
Output isn't correct |
19 |
Incorrect |
278 ms |
29336 KB |
Output isn't correct |
20 |
Incorrect |
317 ms |
27028 KB |
Output isn't correct |