Submission #898827

#TimeUsernameProblemLanguageResultExecution timeMemory
898827hadi7Job Scheduling (CEOI12_jobs)C++17
35 / 100
421 ms15740 KiB
#include<bits/stdc++.h> #define FAST ios::sync_with_stdio(0); cin.tie(0) #define f first #define s second using namespace std ; const int N = 2e6 ; int n , k , m ; vector <pair <int , int>> p ; bool slv(int x) { int u = 0 ; for(int i = 1 ; i <= n ; i++) { for(int j = 0 ; j < x ; j++) { while(p[u].f > i) i++ ; if(p[u].f > i + k) return 0 ; u++ ; if(u == m) return 1 ; } } return 0 ; } main() { cin >> n >> k >> m ; p.resize(m) ; for(int i = 0 ; i < m ; i++) { cin >> p[i].f ; p[i].s = i + 1 ; } sort(p.begin() , p.end()) ; int l = 0 , r = 1e18 ; while(l + 1 < r) { int h = l + (r - l) / 2 ; if(slv(h)) r = h ; else l = h ; } cout << r << endl ; int z = 0 ; for(int i = 0 ; i < m ;) { for(int j = 0 ; j < r && i < m ; j++ , i++) { cout << p[i].s << " " ; } cout << 0 << endl ; z++ ; } for(; z < n ; z++) cout << 0 << endl ; }

Compilation message (stderr)

jobs.cpp:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   33 | main()
      | ^~~~
jobs.cpp: In function 'int main()':
jobs.cpp:46:21: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   46 |     int l = 0 , r = 1e18 ;
      |                     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...