# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
537127 | mgl_diamond | Job Scheduling (CEOI12_jobs) | C++14 | 188 ms | 23320 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.
#include<bits/stdc++.h>
using namespace std;
#define rep(i, l, r) for(int i=l; i<=r; ++i)
#define fod(i, l, r) for(int i=r; i>=l; --i)
#define ll long long
#define ii pair<ll, ll>
#define fi first
#define se second
template<class T> bool umax(T &a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool umin(T &a, T b) { if (a>b) { a=b; return 1; } return 0; }
void setIO(string name) {
ios_base::sync_with_stdio(0); cin.tie(0);
freopen((name+".in").c_str(),"r",stdin);
freopen((name+".out").c_str(),"w",stdout);
}
const double oo=1e18;
int n, d, m;
vector<ii> stX(1000001);
vector<int> ans[100001];
bool f(int x) {
for(int day=1, j=1; day<=m && j<=n; ++day) {
for(int rb=min(n, j+x-1); j<=rb; ++j)
if (day>stX[j].fi+d)
return 0;
}
return 1;
}
void trace(int x) {
for(int day=1, j=1; day<=m && j<=n; ++day)
for(int rb=min(n, j+x-1); j<=rb; ++j)
ans[day].push_back(stX[j].se);
}
int main() {
cin.tie(0) -> sync_with_stdio(0);
cout.tie(0);
cin >> m >> d >> n;
for(int i=1; i<=n; ++i) {
cin >> stX[i].fi;
stX[i].se=i;
}
sort(stX.begin()+1, stX.begin()+n+1);
int lb=0, rb=n+1, mb;
while (lb<rb) {
mb=(lb+rb)>>1;
if (f(mb))
rb=mb;
else
lb=mb+1;
}
trace(lb);
cout << lb << '\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |