Submission #1094071

#TimeUsernameProblemLanguageResultExecution timeMemory
1094071SunbaeJob Scheduling (CEOI12_jobs)C++17
0 / 100
187 ms19024 KiB
#include <bits/stdc++.h> using namespace std; vector<int> v[100000]; int a[1000000]; signed main(){ int n, d, m; scanf("%d %d %d", &n, &d, &m); for(int i = 0; i<m; ++i) scanf("%d", a+i), v[--a[i]].push_back(i); sort(a, a+m); int low = 1, high = m, ans; while(low <= high){ int mid = low + ((high-low)>>1), ch = 1; for(int i = 0; i<m; ++i) if(i/mid > a[i] + d){ ch = 0; break;} if(ch) high = mid-1, ans = mid; else low = mid+1; } int cnt = 0; for(int i = 0, j; i < m; i = j, ++cnt){ for(j = i; j < m && (i/ans) == (j/ans); ++j) printf("%d ", v[a[j]].back() + 1), v[a[j]].pop_back(); printf("0\n"); } for(int j = 0; j<n-cnt; ++j) puts("0"); }

Compilation message (stderr)

jobs.cpp: In function 'int main()':
jobs.cpp:6:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  int n, d, m; scanf("%d %d %d", &n, &d, &m);
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
jobs.cpp:7:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  for(int i = 0; i<m; ++i) scanf("%d", a+i), v[--a[i]].push_back(i);
      |                           ~~~~~^~~~~~~~~~~
jobs.cpp:18:36: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   18 |   for(j = i; j < m && (i/ans) == (j/ans); ++j) printf("%d ", v[a[j]].back() + 1), v[a[j]].pop_back();
      |                                  ~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...