#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 + 1);
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 |
12 ms |
2168 KB |
Extra information in the output file |
2 |
Incorrect |
12 ms |
2000 KB |
Extra information in the output file |
3 |
Incorrect |
11 ms |
2000 KB |
Extra information in the output file |
4 |
Incorrect |
12 ms |
2000 KB |
Extra information in the output file |
5 |
Incorrect |
11 ms |
2000 KB |
Extra information in the output file |
6 |
Incorrect |
12 ms |
2000 KB |
Extra information in the output file |
7 |
Incorrect |
12 ms |
2000 KB |
Extra information in the output file |
8 |
Incorrect |
13 ms |
2000 KB |
Extra information in the output file |
9 |
Incorrect |
19 ms |
4432 KB |
Output isn't correct |
10 |
Incorrect |
19 ms |
4432 KB |
Output isn't correct |
11 |
Incorrect |
11 ms |
1872 KB |
Output isn't correct |
12 |
Incorrect |
21 ms |
3152 KB |
Output isn't correct |
13 |
Incorrect |
32 ms |
4936 KB |
Output isn't correct |
14 |
Incorrect |
55 ms |
6216 KB |
Output isn't correct |
15 |
Incorrect |
53 ms |
7228 KB |
Output isn't correct |
16 |
Incorrect |
76 ms |
9032 KB |
Output isn't correct |
17 |
Incorrect |
89 ms |
11052 KB |
Output isn't correct |
18 |
Incorrect |
84 ms |
11084 KB |
Output isn't correct |
19 |
Incorrect |
111 ms |
13900 KB |
Output isn't correct |
20 |
Incorrect |
91 ms |
10824 KB |
Output isn't correct |