제출 #791563

#제출 시각아이디문제언어결과실행 시간메모리
791563I_FloPPed21Job Scheduling (CEOI12_jobs)C++14
0 / 100
1 ms328 KiB
#include <fstream> #include <algorithm> using namespace std; ifstream cin("jobs.in"); ofstream cout("jobs.out"); long long n, d, m ; struct neveu { int a, b ; } v [ 1000005 ]; bool check(long long caz ) { int ziua = 1 ; for ( int i = 1; i <= m ; i += caz, ziua ++ ) { if ( v[ i ].a < ziua ) return false ; if ( ziua > n ) return false ; } return true ; } bool compare ( neveu x, neveu y) { return ( x. a < y . a ); } int main() { cin >> n >> d >> m ; for ( int i = 1; i <= m ; i ++ ) { cin >> v[ i ].a ; v [ i ].a += d ; v [ i] . b = i ; } sort ( v + 1, v + m + 1, compare) ; long long poz = 1e9 ; int st = 1, dr = m ; while ( st <= dr ) { long long mij = ( st + dr ) / 2 ; if ( check ( mij ) == true ) { poz = mij ; dr = mij - 1; } else st = mij + 1; } cout << 50000 << '\n' ; long long masini = poz ; long long ziua = 1 ; for ( int i = 1; i <= m ; i ++ ) { cout << v [ i ].b << " "; masini -- ; if ( masini == 0 ) { cout << 0 << '\n'; masini = poz ; ziua ++ ; } else if ( i == m ) { cout << 0 << '\n'; ziua ++ ; } } while ( ziua <= n ) { cout << 0 << '\n'; ziua ++ ; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...