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