Submission #66300

#TimeUsernameProblemLanguageResultExecution timeMemory
66300ikura355Job Scheduling (CEOI12_jobs)C++14
100 / 100
376 ms13860 KiB
#include<bits/stdc++.h> using namespace std; #define pii pair<int,int> #define X first #define Y second const int maxn = 1e6 + 5; int n,d,m; pii a[maxn]; bool check(int num) { int cur = 0; for(int day=0;day<n;day++) { for(int i=0;i<num;i++) { if(cur<m && a[cur].X<=day+1 && a[cur].X+d>=day+1) cur++; else break; } } return cur==m; } int main() { scanf("%d%d%d",&n,&d,&m); for(int i=0;i<m;i++) scanf("%d",&a[i].X), a[i].Y = i+1; sort(&a[0],&a[m]); int l = 0, r = m, mid, res = -1; while(l<=r) { mid = (l+r)/2; if(check(mid)) { res = mid; r = mid-1; } else l = mid+1; } printf("%d\n",res); int cur = 0; for(int day=0;day<n;day++) { for(int i=0;i<res;i++) { if(cur<m && a[cur].X<=day+1 && a[cur].X+d>=day+1) { printf("%d ",a[cur].Y); cur++; } else break; } printf("0\n"); } }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&d,&m);
  ~~~~~^~~~~~~~~~~~~~~~~~~
jobs.cpp:26:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<m;i++) scanf("%d",&a[i].X), a[i].Y = i+1;
                       ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...