# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
79776 | psmao | Job Scheduling (CEOI12_jobs) | C++14 | 275 ms | 13412 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 fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;
void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}
const int maxn = 1000050;
int n, d, m;
pair<int,int> a[maxn];
bool jud(int x)
{
int j = 1, tmp = 0;
for(int i = 1; i <= n; ++ i)
{
while(j <= m && a[j].fi + d < i) ++ j;
tmp = x;
while(j <= m && a[j].fi + d >= i && tmp > 0) {-- tmp; ++ j;}
}
return (j > m);
}
void go(int x)
{
int j = 1, tmp = 0;
for(int i = 1; i <= n; ++ i)
{
while(j <= m && a[j].fi + d < i) ++ j;
tmp = x;
while(j <= m && a[j].fi + d >= i && tmp > 0) {pf("%d ",a[j].se); -- tmp; ++ j;}
pf("0\n");
}
}
int main()
{
#ifdef MPS
fp("1.in","r",stdin);
fp("1.out","w",stdout);
db mps = clock();
#endif
sf("%d%d%d",&n,&d,&m);
fo(i,1,m) sf("%d",&a[i].fi), a[i].se = i;
sort(a+1,a+m+1);
int l = 1, r = m, mid, ans;
while(l <= r)
{
mid = (l + r) >> 1;
if(jud(mid)) ans = mid, r = mid - 1;
else l = mid + 1;
}
pf("%d\n",ans);
go(mid);
#ifdef MPS
pf("Time Elapsed: %.3fms\n",clock()-mps);
#endif
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |