//In His Name
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
#define F first
#define S second
#define pb push_back
#define bug(x) cout << "Ah shit , here we go again : " << x <<endl
#define all(x) x.begin() , x.end()
#define ceil(x,y) x/y + min(1ll,x%y)
const int maxn = 5e3 + 10, MOD = 1e9 + 7;
const ll INF = 1e18;
int n , d , m;
vector<pii> v;
bool check(int mid){
vector<pii> s;
for(pii i : v) s.pb(i);
int cnt = 1 , flag = 0;
for(int i = 0 ; i < s.size(); i++){
if(cnt - s[i].F > d) return false;
if(cnt < s[i].F) flag = 0 , cnt++ ;
flag++;
if(flag == mid) flag = 0 , cnt++;
}
if(flag == 0) cnt--;
if(cnt > n) return false;
return true;
}
void Find_Ans(int x){
int j = 0;
for(int i = 0 ; i < n ; i++){
int cnt = 0;
while(cnt < x and v[j].F <= i+1){
cnt++;
cout<< v[j].S <<" ";
j++;
}
cout << "0\n";
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin >> n >> d >> m;
for(int i = 1 ; i <= m ; i++){
int x;
cin >> x;
v.pb({x,i});
}
sort(all(v));
int l = 1 , r = 1e9;
while(r - l > 1){
int mid = (l+r) >> 1;
if(check(mid)) r = mid;
else l = mid;
}
cout << r << "\n";
Find_Ans(r);
}
Compilation message
jobs.cpp: In function 'bool check(long long int)':
jobs.cpp:24:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(int i = 0 ; i < s.size(); i++){
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
58 ms |
5864 KB |
Execution killed with signal 11 |
2 |
Runtime error |
51 ms |
5752 KB |
Execution killed with signal 11 |
3 |
Runtime error |
53 ms |
5844 KB |
Execution killed with signal 11 |
4 |
Runtime error |
51 ms |
5776 KB |
Execution killed with signal 11 |
5 |
Runtime error |
51 ms |
5776 KB |
Execution killed with signal 11 |
6 |
Runtime error |
51 ms |
5792 KB |
Execution killed with signal 11 |
7 |
Runtime error |
53 ms |
5792 KB |
Execution killed with signal 11 |
8 |
Runtime error |
51 ms |
5792 KB |
Execution killed with signal 11 |
9 |
Runtime error |
57 ms |
5848 KB |
Execution killed with signal 11 |
10 |
Runtime error |
57 ms |
5740 KB |
Execution killed with signal 11 |
11 |
Incorrect |
47 ms |
6204 KB |
Expected EOLN |
12 |
Correct |
101 ms |
10996 KB |
Output is correct |
13 |
Incorrect |
172 ms |
19124 KB |
Expected EOLN |
14 |
Correct |
230 ms |
23548 KB |
Output is correct |
15 |
Incorrect |
252 ms |
24720 KB |
Extra information in the output file |
16 |
Runtime error |
349 ms |
37288 KB |
Memory limit exceeded |
17 |
Runtime error |
393 ms |
41120 KB |
Memory limit exceeded |
18 |
Runtime error |
455 ms |
44324 KB |
Execution killed with signal 11 |
19 |
Runtime error |
479 ms |
47620 KB |
Execution killed with signal 11 |
20 |
Runtime error |
404 ms |
41180 KB |
Memory limit exceeded |