Submission #571031

#TimeUsernameProblemLanguageResultExecution timeMemory
571031elesisJob Scheduling (CEOI12_jobs)C++14
80 / 100
470 ms45532 KiB
#include<bits/stdc++.h> using namespace std; #define fast ios_base::sync_with_stdio(false);cin.tie(0); #define int long long #define pii pair<int,int> #define ff first #define ss second const int inf=1e11+7; const int mod =1000000007; int binpow(int a,int b,int m) { a %= m; int res = 1; while(b>0) { if (b&1) { res=res*a%m; } a=a*a%m; b>>=1; } return res; } int N,M,D; pair<bool, vector<vector <int>>> ok(vector<pii> &arr, int x) { vector <vector <int>> nub(N); int job=0; for(int i=1;i<=N;i++) { for(int j=0;j<x;j++) { if(arr[job].ff>i) { break; } if(arr[job].ff+D>=i) { nub[i-1].push_back(arr[job].ss); job++; } else { return {false,nub}; } if(job==M) { return {true,nub}; } } } return {false,nub}; } void solve() { cin>>N>>D>>M; int ans; vector <pii> arr(M); for(int i=0;i<M;i++) { cin>>arr[i].first; arr[i].second=i+1; } sort(arr.begin(),arr.end()); vector <vector <int>> res; int lo=1,hi=M; while(lo<hi) { int mid=(lo+hi)/2; pair <bool,vector <vector <int>>> ef=ok(arr,mid); if(ef.ff) { ans=mid; res=ef.ss; hi=mid; } else { lo=mid+1; } } cout << lo << "\n"; for(int i=0;i<N;i++) { for(auto it:res[i]) { cout << it << " " ; } cout << 0 << "\n"; } } signed main() { fast clock_t start, end; start = clock(); solve(); end = clock(); double time_taken=double(end-start)/double(CLOCKS_PER_SEC); //cout << "time taken" << " " << time_taken << "\n"; }

Compilation message (stderr)

jobs.cpp: In function 'void solve()':
jobs.cpp:58:9: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
   58 |     int ans;
      |         ^~~
jobs.cpp: In function 'int main()':
jobs.cpp:100:12: warning: unused variable 'time_taken' [-Wunused-variable]
  100 |     double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
      |            ^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...