#include <bits/stdc++.h>
using namespace std;
bool check(int x, int n, vector<pair<int,int>> &allJobs, bool finall, int m, int d)
{
int ptr = 1;
for(int i = 1; i <= n;i++)
{
int ct = 0;
while(ptr <= m && allJobs[ptr].first <= i && ct < x)
{
if(allJobs[ptr].first + d >= i)
{
ptr++;
}
else
{
return false;
}
if(finall)
{
cout << allJobs[ptr-1].second << " ";
}
ct++;
}
if(finall)
{
cout << 0 << "\n";
}
}
if(ptr <= m)
{
return false;
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, d, m;
cin >> n >> d >> m;
vector<pair<int,int>> allJobs;
allJobs.push_back({0, 0});
for (int i = 0; i < m; i++)
{
int x;
cin >> x;
allJobs.push_back({x, i+1});
}
sort(allJobs.begin(), allJobs.end());
int left = 0;
int right = m;
while(left < right)
{
int mid = (left + right) >> 1;
if (check(mid, n, allJobs, 0, m, d))
{
right = mid;
}
else
{
left = mid + 1;
}
}
auto z = check(left, n, allJobs, 1, m, d);
}
Compilation message
jobs.cpp: In function 'int main()':
jobs.cpp:74:10: warning: unused variable 'z' [-Wunused-variable]
auto z = check(left, n, allJobs, 1, m, d);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
1912 KB |
Output isn't correct |
2 |
Incorrect |
33 ms |
1904 KB |
Output isn't correct |
3 |
Incorrect |
25 ms |
1916 KB |
Output isn't correct |
4 |
Incorrect |
28 ms |
1904 KB |
Output isn't correct |
5 |
Incorrect |
36 ms |
1904 KB |
Output isn't correct |
6 |
Incorrect |
32 ms |
1804 KB |
Output isn't correct |
7 |
Incorrect |
43 ms |
1904 KB |
Output isn't correct |
8 |
Incorrect |
22 ms |
1912 KB |
Output isn't correct |
9 |
Incorrect |
39 ms |
2004 KB |
Expected EOLN |
10 |
Incorrect |
39 ms |
2040 KB |
Expected EOLN |
11 |
Incorrect |
29 ms |
1776 KB |
Expected EOLN |
12 |
Incorrect |
60 ms |
3304 KB |
Expected EOLN |
13 |
Incorrect |
96 ms |
4724 KB |
Expected EOLN |
14 |
Incorrect |
140 ms |
6292 KB |
Expected EOLN |
15 |
Incorrect |
155 ms |
7780 KB |
Expected EOLN |
16 |
Incorrect |
228 ms |
9300 KB |
Expected EOLN |
17 |
Incorrect |
268 ms |
10780 KB |
Expected EOLN |
18 |
Incorrect |
309 ms |
12144 KB |
Expected EOLN |
19 |
Incorrect |
316 ms |
13712 KB |
Expected EOLN |
20 |
Incorrect |
257 ms |
10840 KB |
Expected EOLN |