// Dost SEFEROĞLU
#include "bits/stdc++.h"
//#include "windows.h"
#define int long long
#define mx(a, b) ((a) > (b) ? (a) : (b))
#define mn(a, b) ((a) < (b) ? (a) : (b))
constexpr int mod = 1000000007;
int d;
int n;
bool firsttrue(int mid, int a[], int m) {
if(mid >= m) {
return 1;
}
int currday = 1;
int i = 0;
int maxdelay = 0;
while(i < m && currday <= n) {
maxdelay=mx(maxdelay, currday-a[i]);
++currday;
i+=mid;
if(maxdelay > d) return 0;
}
return 1;
}
bool customsort(std::pair<int,int> a, std::pair<int,int> b) {
return a.second < b.second;
}
void solve() {
int m;
std::cin>>n>>d>>m;
int a[m];
std::unordered_map<int,int> mp;
for(int i = 0; i < m; ++i) {
std::cin>>a[i];
mp[i] = a[i];
}
std::vector<std::pair<int,int>> v(mp.begin(), mp.end());
std::sort(v.begin(), v.end(), customsort);
std::sort(a,a+m);
int l = 1; int r = 100001;
int ans = -1;
while(l<=r) {
int mid = (l+r)/2;
if(firsttrue(mid,a,m)) {
ans=mid;
r=mid-1;
}
else {
l=mid+1;
}
}
std::cout<<ans<<"\n";
int curr = 0;
for(auto i : v) {
if(curr==0) {
std::cout<<i.first+1<<" ";
++curr;
}
else if(curr%ans == 0) {
std::cout<<i.first+1<<" 0\n";
}
else {
std::cout<<i.first+1<<" ";
}
++curr;
}
for(int i = curr/2; i < n; ++i) {
std::cout<<0<<"\n";
}
//std::cout<<curr<<"\n";
}
signed main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
auto start = std::chrono::high_resolution_clock::now();
#endif
int t = 1;
//std::cin >> t;
while (t--) {
solve();
}
#ifdef LOCAL
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = end - start;
std::cout << elapsed.count() << " seconds\n";
#endif
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
8140 KB |
Output isn't correct |
2 |
Incorrect |
19 ms |
8136 KB |
Output isn't correct |
3 |
Incorrect |
20 ms |
8132 KB |
Output isn't correct |
4 |
Incorrect |
27 ms |
8020 KB |
Output isn't correct |
5 |
Incorrect |
21 ms |
7968 KB |
Output isn't correct |
6 |
Incorrect |
19 ms |
8144 KB |
Output isn't correct |
7 |
Incorrect |
20 ms |
8092 KB |
Output isn't correct |
8 |
Incorrect |
21 ms |
8144 KB |
Output isn't correct |
9 |
Incorrect |
24 ms |
8132 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
25 ms |
8140 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
28 ms |
8144 KB |
Unexpected end of file - int32 expected |
12 |
Correct |
57 ms |
16208 KB |
Output is correct |
13 |
Incorrect |
81 ms |
22648 KB |
Unexpected end of file - int32 expected |
14 |
Correct |
120 ms |
32448 KB |
Output is correct |
15 |
Runtime error |
137 ms |
38592 KB |
Memory limit exceeded |
16 |
Runtime error |
177 ms |
45868 KB |
Memory limit exceeded |
17 |
Runtime error |
213 ms |
52408 KB |
Memory limit exceeded |
18 |
Runtime error |
222 ms |
64044 KB |
Memory limit exceeded |
19 |
Runtime error |
249 ms |
65536 KB |
Execution killed with signal 9 |
20 |
Runtime error |
214 ms |
52416 KB |
Memory limit exceeded |