# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
418132 | freshmintt | Job Scheduling (CEOI12_jobs) | C++11 | 3 ms | 332 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>
#define MAXN 10 //change
using namespace std;
typedef pair<long long,long long> pi;
typedef long long ll;
typedef long double ld;
ll N, D, M;
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll jobs[MAXN];
ll days[MAXN];
bool works(ll machs) {
fill(days, days+MAXN, 0);
for (int i=0; i < N; i++) {
ll machID = i % machs;
days[machID]++;
if ((days[machID] - jobs[i]) > D) return false;
}
return true;
}
int main() {
freopen("in", "r", stdin); // comment out
FIO;
cin >> N >> D >> M;
for (int i = 0; i < N; i ++) cin >> jobs[i];
ll a = 1; ll b = 1E9; ll mid;
while (a != b) {
mid = (a+b)/2;
if (works(mid)) {
b = mid;
}
else {
a = mid + 1;
}
}
cout << mid;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |