제출 #32023

#제출 시각아이디문제언어결과실행 시간메모리
32023chonkaJob Scheduling (CEOI12_jobs)C++98
100 / 100
496 ms24956 KiB
#include<iostream> #include<stdio.h> #include<vector> #include<queue> using namespace std ; #define MAXN 100007 int n , d , m ; vector < int > v[ MAXN ] ; vector < int > ans[ MAXN ] ; int pos[ 10 * MAXN ] ; int rev[ 10 * MAXN ] ; bool f ( int x ) { queue < pair < int , int > > q ; int i , j , sz ; for ( i = 1 ; i <= n ; i ++ ) { sz = v[ i ].size ( ) ; for ( j = 0 ; j < sz ; j ++ ) { q.push ( make_pair ( v[ i ][ j ] , i + d ) ) ; } ans[ i ].clear ( ) ; int lft = x ; while ( lft != 0 && q.empty ( ) == false ) { pair < int , int > p = q.front ( ) ; if ( p.second < i ) { return false ; } lft -- ; q.pop ( ) ; ans[ i ].push_back ( p.first ) ; } } return true ; } void input ( ) { scanf ( "%d%d%d" , &n , &d , &m ) ; int i ; for ( i = 1 ; i <= m ; i ++ ) { int x ; scanf ( "%d" , &x ) ; v[ x ].push_back ( i ) ; } } void solve ( ) { int l , r , mid ; l = 1 ; r = m ; while ( r - l > 3 ) { mid = ( l + r ) / 2 ; if ( f ( mid ) == true ) { r = mid ; } else { l = mid ; } } while ( f ( l ) == false ) { l ++ ; } f ( l ) ; printf ( "%d\n" , l ) ; int i , j ; int sz ; for ( i = 1 ; i <= n ; i ++ ) { sz = ans[ i ].size ( ) ; for ( j = 0 ; j < sz ; j ++ ) { printf ( "%d " , ans[ i ][ j ] ) ; } printf ( "0\n" ) ; } } int main ( ) { input ( ) ; solve ( ) ; return 0 ; }

컴파일 시 표준 에러 (stderr) 메시지

jobs.cpp: In function 'void input()':
jobs.cpp:39:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ( "%d%d%d" , &n , &d , &m ) ;
                                       ^
jobs.cpp:43:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ( "%d" , &x ) ;
                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...