Submission #79777

#TimeUsernameProblemLanguageResultExecution timeMemory
79777psmaoJob Scheduling (CEOI12_jobs)C++14
45 / 100
350 ms13080 KiB
#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) { if(j > m) break; if(a[j].fi + d < i) return false; if(a[j].fi > i) continue; 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) { tmp = x; if(a[j].fi > i) continue; 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 = -1; 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)

jobs.cpp: In function 'int main()':
jobs.cpp:69:4: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  sf("%d%d%d",&n,&d,&m);
    ^
jobs.cpp:70:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fo(i,1,m) sf("%d",&a[i].fi), a[i].se = i;
                             ^
jobs.cpp:80:4: warning: 'mid' may be used uninitialized in this function [-Wmaybe-uninitialized]
  go(mid);
  ~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...