# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
130696 | MohamedAhmed04 | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 1092 ms | 40244 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std ;
const int MAX = 1e7 + 5 ;
const int OO = 1e9 ;
int dp[MAX] ;
int main()
{
int n , q ;
scanf("%d %d" , &n , &q) ;
int arr[n] ;
for(int i = 0 ; i < n ; ++i)
scanf("%d" , &arr[i]) ;
priority_queue< pair<int , int> , vector< pair<int , int> > , greater< pair<int , int> > >pq ;
multiset<int>s ;
for(int i = 0 ; i < n ; ++i)
{
pq.push({arr[i] , arr[i]}) ;
s.insert(0) ;
}
dp[0] = 0 ;
const int cons = 1e7 ;
for(int i = 1 ; i <= cons ; ++i)
{
while(pq.size() > 0)
{
pair<int , int>pp = pq.top() ;
if(pp.first == i)
{
pq.pop() ;
pq.push({pp.first + pp.second , pp.second}) ;
s.erase(s.find(pp.first - pp.second)) ;
s.insert(pp.first) ;
}
else
break ;
}
int x = *s.begin() ;
if(x == i)
dp[i] = OO ;
else
dp[i] = dp[x] + 1 ;
}
while(q--)
{
int x ;
scanf("%d" , &x) ;
if(dp[x] >= OO)
cout<<"oo\n" ;
else
cout<<dp[x]<<"\n";
}
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... |