#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,d,m;
vector<int> a,index_v,tmp_v,ans_v;
bool is_ok(int machine)
{
// printf("machine=%d\n",machine);
tmp_v.clear();
bool x=false;
int i=0,cnt=1;
for(;cnt<=n;++cnt)
{
// printf("cnt=%d\n",cnt);
int _m=machine;
while(i<a.size()&&_m-->0) tmp_v.push_back(index_v[i++]);
if(i==a.size()) {x=true;break;}
tmp_v.push_back(0);
}
while(cnt++<=n) tmp_v.push_back(0);
return x;
}
main()
{
ios::sync_with_stdio(0),cin.tie(0);
cin>>n>>d>>m;
vector<pair<int,int>> tmp(m);
for(int i=0;i<m;++i) cin>>tmp[i].first,tmp[i].second=i+1;
sort(tmp.begin(),tmp.end());
for(auto it:tmp) a.push_back(it.first),index_v.push_back(it.second);
// for(auto it:a) cout<<it.num<<' '<<it.index<<'\n';
int l=0,r=m+1,ans=m+1;
while(l<=r)
{
int mid=(r-l)/2+l;
if(is_ok(mid)) ans_v=tmp_v,ans=mid,r=mid-1;
else l=mid+1;
}
cout<<ans<<'\n';
for(auto it:ans_v)
{
cout<<it<<' ';
if(it==0) cout<<'\n';
}
return 0;
}
/*
8 2 12
1 1 2 2 2 3 3 4 4 5 6 6
8 2 12
1 2 4 2 1 3 5 6 2 3 6 4
2
5 1 0
9 4 0
2 10 0
6 12 0
3 7 0
11 8 0
0
0
*/
Compilation message
jobs.cpp: In function 'bool is_ok(long long int)':
jobs.cpp:16:10: 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]
16 | while(i<a.size()&&_m-->0) tmp_v.push_back(index_v[i++]);
| ~^~~~~~~~~
jobs.cpp:17:7: 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]
17 | if(i==a.size()) {x=true;break;}
| ~^~~~~~~~~~
jobs.cpp: At global scope:
jobs.cpp:23:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
23 | main()
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
5948 KB |
Output isn't correct |
2 |
Incorrect |
20 ms |
5960 KB |
Output isn't correct |
3 |
Incorrect |
22 ms |
5960 KB |
Output isn't correct |
4 |
Incorrect |
20 ms |
5956 KB |
Output isn't correct |
5 |
Incorrect |
20 ms |
5960 KB |
Output isn't correct |
6 |
Incorrect |
21 ms |
5960 KB |
Output isn't correct |
7 |
Incorrect |
20 ms |
5956 KB |
Output isn't correct |
8 |
Incorrect |
20 ms |
5956 KB |
Output isn't correct |
9 |
Incorrect |
38 ms |
7736 KB |
Output isn't correct |
10 |
Incorrect |
38 ms |
7736 KB |
Output isn't correct |
11 |
Incorrect |
26 ms |
5848 KB |
Output isn't correct |
12 |
Incorrect |
53 ms |
11060 KB |
Expected EOLN |
13 |
Incorrect |
81 ms |
17944 KB |
Output isn't correct |
14 |
Incorrect |
115 ms |
23232 KB |
Expected EOLN |
15 |
Incorrect |
131 ms |
27424 KB |
Output isn't correct |
16 |
Runtime error |
165 ms |
35128 KB |
Memory limit exceeded |
17 |
Runtime error |
196 ms |
40972 KB |
Memory limit exceeded |
18 |
Runtime error |
218 ms |
45156 KB |
Memory limit exceeded |
19 |
Runtime error |
259 ms |
50792 KB |
Memory limit exceeded |
20 |
Runtime error |
194 ms |
41460 KB |
Memory limit exceeded |