#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define vpii vector<pair<int, int>>
#define vii vector<vector<int>>
#define vi vector<int>
// void setIO(string name = "") {
// cin.tie(0)->sync_with_stdio(0);
// if (name.size()) {
// freopen((name + ".in").c_str(), "r", stdin);
// freopen((name + ".out").c_str(), "w", stdout);
// }
// }
int n,d,m;
vector<vector<int>> days;
bool check(int x)
{
int jobs_remain[100005], index = 1;
for (int i = 1; i <= n; i++)
{
if(i > index + d) return false;
jobs_remain[i] = days[i].size();
jobs_remain[index] -= x;
if(jobs_remain[index] <= 0) index++;
}
return true;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> d >> m;
days.resize(n);
int num;
for (int i = 1; i <= m; i++)
{
cin >> num;
days[num].emplace_back(i);
}
int l = 0, r = m + 5,mid;
while(l < r)
{
mid = l + (r - l) / 2;
if(check(mid))
r = mid;
else
l = mid + 1;
}
cout << r << '\n';
int index,temp;
for (int i = 1; i <= n; i++)
{
index = 0;
while(index < days[i].size())
{
temp = 1;
while(temp <= r && index < days[i].size())
{
cout << days[i][index] << ' ';
index++,temp++;
if(temp <= r && index == days[i].size())
{
i++;
index = 0;
}
}
cout << 0 << '\n';
}
if(!index) cout << 0 << '\n';
}
return 0;
}
Compilation message
jobs.cpp: In function 'int main()':
jobs.cpp:62:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
62 | while(index < days[i].size())
| ~~~~~~^~~~~~~~~~~~~~~~
jobs.cpp:65:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
65 | while(temp <= r && index < days[i].size())
| ~~~~~~^~~~~~~~~~~~~~~~
jobs.cpp:70:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
70 | if(temp <= r && index == days[i].size())
| ~~~~~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
2244 KB |
Extra information in the output file |
2 |
Incorrect |
13 ms |
2512 KB |
Extra information in the output file |
3 |
Incorrect |
12 ms |
2516 KB |
Extra information in the output file |
4 |
Incorrect |
12 ms |
2512 KB |
Extra information in the output file |
5 |
Incorrect |
13 ms |
2512 KB |
Extra information in the output file |
6 |
Incorrect |
13 ms |
2512 KB |
Extra information in the output file |
7 |
Incorrect |
12 ms |
2512 KB |
Extra information in the output file |
8 |
Incorrect |
13 ms |
2256 KB |
Extra information in the output file |
9 |
Incorrect |
18 ms |
4688 KB |
Output isn't correct |
10 |
Incorrect |
19 ms |
4688 KB |
Output isn't correct |
11 |
Runtime error |
16 ms |
3408 KB |
Execution killed with signal 11 |
12 |
Runtime error |
25 ms |
5576 KB |
Execution killed with signal 11 |
13 |
Runtime error |
37 ms |
9040 KB |
Execution killed with signal 11 |
14 |
Incorrect |
55 ms |
8272 KB |
Output isn't correct |
15 |
Runtime error |
63 ms |
12872 KB |
Execution killed with signal 11 |
16 |
Incorrect |
84 ms |
10348 KB |
Output isn't correct |
17 |
Incorrect |
95 ms |
14284 KB |
Output isn't correct |
18 |
Incorrect |
89 ms |
14160 KB |
Output isn't correct |
19 |
Incorrect |
111 ms |
17428 KB |
Output isn't correct |
20 |
Incorrect |
95 ms |
14160 KB |
Output isn't correct |