제출 #79772

#제출 시각아이디문제언어결과실행 시간메모리
79772psmaoJob Scheduling (CEOI12_jobs)C++14
45 / 100
329 ms33792 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) { while(j <= m && a[j].fi > 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 > 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; }

컴파일 시 표준 에러 (stderr) 메시지

jobs.cpp: In function 'int main()':
jobs.cpp:67: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:68: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:78:4: warning: 'mid' may be used uninitialized in this function [-Wmaybe-uninitialized]
  go(mid);
  ~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...