Submission #862110

#TimeUsernameProblemLanguageResultExecution timeMemory
862110vjudge1Job Scheduling (CEOI12_jobs)C++14
85 / 100
226 ms36872 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n,d,m; vector<int> a,index_v; bool is_ok(int machine) { // printf("machine=%d\n",machine); int ptr=0; for(int day=1;day<=n;++day) { for(int i=0;i<machine;++i) { // printf("ptr=%d\n",ptr); if(ptr>=a.size()) return true; if(a[ptr]>day) break; if(a[ptr]+d<day) { // printf("{%d,%d},FALSE0\n",a[ptr]+d,day); return false; } ++ptr; } } return (ptr>=a.size()); } void yes(int machine) { // printf("machine=%d\n",machine); int ptr=0; for(int day=1;day<=n;++day) { for(int i=0;i<machine;++i) { // printf("ptr=%d\n",ptr); if(ptr>=a.size()) break; if(a[ptr]>day) break; cout<<index_v[ptr]<<' '; ++ptr; } cout<<0<<'\n'; } } main() { ios::sync_with_stdio(0),cin.tie(0); cin>>n>>d>>m; vector<pair<int,int>> tmp(m); for(int i=0;i<m;++i) cin>>tmp[i].first,tmp[i].second=i+1; sort(tmp.begin(),tmp.end()); for(auto it:tmp) a.push_back(it.first),index_v.push_back(it.second); int l=0,r=1e9,ans=1e9; while(l<=r) { int mid=(r-l)/2+l; if(is_ok(mid)) ans=mid,r=mid-1; else l=mid+1; } assert(n*ans>=m); cout<<ans<<'\n'; yes(ans); return 0; } /* 8 2 12 1 2 4 2 1 3 5 6 2 3 6 4 */

Compilation message (stderr)

jobs.cpp: In function 'bool is_ok(long long int)':
jobs.cpp:15:10: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |    if(ptr>=a.size()) return true;
      |       ~~~^~~~~~~~~~
jobs.cpp:25:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  return (ptr>=a.size());
      |          ~~~^~~~~~~~~~
jobs.cpp: In function 'void yes(long long int)':
jobs.cpp:36:10: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    if(ptr>=a.size()) break;
      |       ~~~^~~~~~~~~~
jobs.cpp: At global scope:
jobs.cpp:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   44 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...