# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
49080 | updown1 | Job Scheduling (CEOI12_jobs) | C++17 | 333 ms | 32768 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;
typedef long long ll;
#define For(i, a, b) for(int i=a; i<b; i++)
#define ffi For(i, 0, N)
#define ffj For(j, 1, M+1)
#define ffa ffi ffj
#define s <<" "<<
#define w cout
#define e "\n"
#define pb push_back
#define mp make_pair
#define a first
#define b second
//#define int ll
const int MAXN=1000000;//, INF=1000000000000000000;
///500,000,000
int D, N, M;
pair<int, int> inp[MAXN];
bool works(int m) {
int day = 1;
int lef = m;
ffi {
if (inp[i].a > day) day=inp[i].a, lef = m;
if (inp[i].a + D < day) return false;
lef--;
if (lef == 0) day++, lef=m;
}
return true;
}
int main() {
//ifstream cin("test.in");
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> M >> D >> N;
ffi {cin >> inp[i].a; inp[i].b = i+1;}
sort(inp, inp+N);
int a=1, b=N;
while (a != b) {
int mid = (a+b)/2;
if (works(mid)) b = mid;
else a = mid+1;
}
w<< a<<e;
int at = 0;
ffj {
int cnt = 0;
while (at != N && inp[at].a <= j && cnt <a) {
cnt++;
w<< inp[at].b<< " ";
at++;
}
w<< 0<<e;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |