# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
916223 | a_l_i_r_e_z_a | Job Scheduling (CEOI12_jobs) | C++17 | 245 ms | 36548 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// In the name of God
// Hope is last to die
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb push_back
#define S second
#define F first
#define mp make_pair
#define smax(x, y) (x) = max((x), (y))
#define smin(x, y) (x) = min((x), (y))
#define all(x) (x).begin(), (x).end()
#define len(x) ((int)(x).size())
const int maxn = 1e5 + 5, maxm = 1e6 + 5;
const int inf = 1e9 + 7;
int n, d, m;
pii a[maxm];
vector<int> vec[maxn];
bool check(int k){
int cur = 0;
for(int i = 1; i <= n; i++){
vec[i].clear();
int cnt = 0;
while(cnt < k && cur < m && a[cur].F <= i && a[cur].F + d <= i){
vec[i].pb(a[cur].S);
cnt++;
cur++;
}
}
if(cur != m) return 0;
return 1;
}
int32_t main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> d >> m;
for(int i = 0; i < m; i++){
cin >> a[i].F;
a[i].S = i + 1;
}
sort(a, a + m);
int l = 0, r = m + 1;
while(r - l > 1){
int mid = (l + r) / 2;
if(check(mid)) r = mid;
else l = mid;
}
cout << l + 1 << '\n';
check(l + 1);
for(int i = 1; i <= n; i++){
for(auto u: vec[i]) cout << u << ' ';
cout << 0 << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |