#include<bits/stdc++.h>
using namespace std;
vector<pair<int, int>> arr;
int n, m , d;
map<int, set<int>> day;
map<int, int> mac;
bool f(int mm){
mac.clear();
day.clear();
int del = 0;
mac[1] += mm;
for(int i=0;i<m;i++){
auto it = mac.lower_bound(-1);
int r = (*it).first;
// cout<<(*it).first<<endl;
del = max(r - arr[i].first, d);
day[r].insert(arr[i].second);
mac[r + 1]++;
if(mac[r] > 1) mac[r]--;
else mac.erase(r);
}
return del <= d;
}
int main(){
cin>>n>>d>>m;
arr.resize(m);
for(int i=0;i<m;i++){
arr[i].second = i;
cin>>arr[i].first;
}
sort(arr.begin(), arr.end());
int mm;
int r = m;
int l = 1;
int ans = -1;
while(r >= l){
mm = l + (r - l)/2;
if(f(mm)){
r = mm - 1;
ans = mm;
}
else{
l = mm + 1;
}
}
f(ans);
for(auto i : day){
cout<<i.first<<" ";
for(auto t : i.second) cout<<t+1<<" ";
cout<<"0 \n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
182 ms |
6588 KB |
Expected EOLN |
2 |
Incorrect |
181 ms |
6604 KB |
Expected EOLN |
3 |
Incorrect |
178 ms |
6412 KB |
Expected EOLN |
4 |
Incorrect |
168 ms |
6428 KB |
Expected EOLN |
5 |
Incorrect |
170 ms |
6388 KB |
Expected EOLN |
6 |
Incorrect |
197 ms |
6480 KB |
Expected EOLN |
7 |
Incorrect |
200 ms |
6424 KB |
Expected EOLN |
8 |
Incorrect |
178 ms |
6484 KB |
Expected EOLN |
9 |
Incorrect |
211 ms |
6668 KB |
Expected EOLN |
10 |
Incorrect |
192 ms |
6680 KB |
Expected EOLN |
11 |
Incorrect |
258 ms |
6596 KB |
Expected EOLN |
12 |
Incorrect |
539 ms |
12744 KB |
Expected EOLN |
13 |
Execution timed out |
1028 ms |
18912 KB |
Time limit exceeded |
14 |
Execution timed out |
1012 ms |
22396 KB |
Time limit exceeded |
15 |
Execution timed out |
1026 ms |
27988 KB |
Time limit exceeded |
16 |
Execution timed out |
1016 ms |
33288 KB |
Time limit exceeded |
17 |
Execution timed out |
1071 ms |
38788 KB |
Time limit exceeded |
18 |
Execution timed out |
1065 ms |
44352 KB |
Time limit exceeded |
19 |
Execution timed out |
1065 ms |
49580 KB |
Time limit exceeded |
20 |
Execution timed out |
1057 ms |
38668 KB |
Time limit exceeded |