#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define ld long double
int const M=2e5+10,M2=1e7+10,mod=1e9+7,inf=1e9+10;
int m,d,a[M];
vector<int>hlp[M];
vector<pii>all;
bool check(int x,bool ch)
{
int day=1,cnt=0;
for(int i=0;i<m;i++)
{
if(cnt==x)day++,cnt=0;
if(day<all[i].F)day=all[i].F,cnt=0;
if(day>all[i].F+d)return 0;
if(ch)hlp[day].pb(all[i].S);
cnt++;
}
return 1;
}
int32_t main()
{
int n;
cin>>n>>d>>m;
for(int i=1;i<=m;i++)
{
cin>>a[i];
all.pb(mp(a[i],i));
}
sort(all.begin(),all.end());
int lo=1,hi=n;
//cout<<check(3)<<endl;
//return 0;
while(hi>lo+1)
{
int mid=(lo+hi)/2;
if(check(mid,0))hi=mid;
else lo=mid+1;
//cerr<<lo<<" "<<hi<<endl;
}
//cerr<<"************"<<endl;
int ans=hi;
if(check(lo,0))ans=lo;
check(ans,1);
cout<<ans<<endl;
int cnt=0;
for(int i=1;i<=n;i++)
{
for(int j=0;j<hlp[i].size();j++)cout<<hlp[i][j]<<" ";
cout<<0<<endl;
}
cout<<0<<endl;
}
Compilation message
jobs.cpp: In function 'int32_t main()':
jobs.cpp:55:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<hlp[i].size();j++)cout<<hlp[i][j]<<" ";
~^~~~~~~~~~~~~~
jobs.cpp:52:6: warning: unused variable 'cnt' [-Wunused-variable]
int cnt=0;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
58 ms |
8044 KB |
Output isn't correct |
2 |
Incorrect |
49 ms |
8456 KB |
Output isn't correct |
3 |
Incorrect |
50 ms |
8868 KB |
Output isn't correct |
4 |
Incorrect |
49 ms |
9272 KB |
Output isn't correct |
5 |
Incorrect |
83 ms |
9624 KB |
Output isn't correct |
6 |
Incorrect |
60 ms |
9952 KB |
Output isn't correct |
7 |
Incorrect |
53 ms |
10148 KB |
Output isn't correct |
8 |
Incorrect |
56 ms |
10428 KB |
Output isn't correct |
9 |
Incorrect |
225 ms |
12096 KB |
Extra information in the output file |
10 |
Incorrect |
195 ms |
12308 KB |
Extra information in the output file |
11 |
Incorrect |
60 ms |
12592 KB |
Extra information in the output file |
12 |
Incorrect |
109 ms |
17352 KB |
Extra information in the output file |
13 |
Incorrect |
87 ms |
17352 KB |
Output isn't correct |
14 |
Incorrect |
124 ms |
17352 KB |
Output isn't correct |
15 |
Incorrect |
119 ms |
17448 KB |
Output isn't correct |
16 |
Incorrect |
149 ms |
18672 KB |
Output isn't correct |
17 |
Incorrect |
131 ms |
19848 KB |
Output isn't correct |
18 |
Incorrect |
124 ms |
20744 KB |
Output isn't correct |
19 |
Incorrect |
229 ms |
21872 KB |
Output isn't correct |
20 |
Incorrect |
131 ms |
23004 KB |
Output isn't correct |