# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
31894 | chonka | Brunhilda’s Birthday (BOI13_brunhilda) | C++98 | 119 ms | 43196 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<stdio.h>
#include<vector>
#include<queue>
using namespace std ;
#define MAXN 100007
int n , m ;
int a[ MAXN ] ;
int b[ MAXN ] ;
int ans[ 100 * MAXN ] ;
int akt[ MAXN ] ;
int lim ;
void input ( ) {
scanf ( "%d%d" , &n , &m ) ;
int i ;
for ( i = 1 ; i <= n ; i ++ ) {
scanf ( "%d" , &a[ i ] ) ;
}
}
void solve ( ) {
lim = 1 ;
int i , j ;
for ( i = 1 ; i <= 7 ; i ++ ) {
lim *= 10 ;
}
deque < pair < int , int > > q ;
for ( i = 1 ; i <= n ; i ++ ) {
q.push_front ( make_pair ( 0 , i ) ) ;
akt[ i ] = 0 ;
}
for ( i = 1 ; i <= lim ; i ++ ) {
while ( q.empty ( ) == false ) {
pair < int , int > p = q.back ( ) ;
if ( p.first + a[ p.second ] <= i ) {
q.push_front ( make_pair ( p.first + a[ p.second ] , p.second ) ) ;
q.pop_back ( ) ;
}
else { break ; }
}
ans[ i ] = ans[ (q.back()).first ] + 1 ;
if ( ans[ q.back().first ] == -1 || (q.back()).first == i ) { ans[ i ] = -1 ; }
}
while ( m != 0 ) {
m -- ;
int x ;
scanf ( "%d" , &x ) ;
if ( ans[ x ] != -1 ) {
printf ( "%d\n" , ans[ x ] ) ;
}
else {
printf ( "oo\n" ) ;
}
}
}
int main ( ) {
input ( ) ;
solve ( ) ;
return 0 ;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |