#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 + 2);
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 temp = 1;
for (int i = 1; i <= n; i++)
{
if(days[i].size() == 0) cout << 0 << '\n';
for (int j = 0; j < days[i].size(); j++)
{
cout << days[i][j] << ' ';
temp++;
if(temp > r)
{
temp = 1;
cout << 0 << '\n';
}
}
}
return 0;
}
Compilation message
jobs.cpp: In function 'int main()':
jobs.cpp:62:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
62 | for (int j = 0; j < days[i].size(); j++)
| ~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
10 ms |
2000 KB |
Extra information in the output file |
2 |
Incorrect |
11 ms |
2256 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 |
11 ms |
2000 KB |
Extra information in the output file |
7 |
Incorrect |
13 ms |
2000 KB |
Extra information in the output file |
8 |
Incorrect |
11 ms |
2000 KB |
Extra information in the output file |
9 |
Incorrect |
18 ms |
4556 KB |
Output isn't correct |
10 |
Incorrect |
19 ms |
4432 KB |
Output isn't correct |
11 |
Incorrect |
12 ms |
2040 KB |
Output isn't correct |
12 |
Incorrect |
27 ms |
3152 KB |
Output isn't correct |
13 |
Incorrect |
31 ms |
4936 KB |
Output isn't correct |
14 |
Incorrect |
58 ms |
6224 KB |
Output isn't correct |
15 |
Incorrect |
56 ms |
7264 KB |
Output isn't correct |
16 |
Incorrect |
119 ms |
9020 KB |
Output isn't correct |
17 |
Incorrect |
123 ms |
10972 KB |
Output isn't correct |
18 |
Incorrect |
83 ms |
11080 KB |
Output isn't correct |
19 |
Incorrect |
107 ms |
13896 KB |
Output isn't correct |
20 |
Incorrect |
109 ms |
10984 KB |
Output isn't correct |