답안 #130696

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
130696 2019-07-15T22:43:35 Z MohamedAhmed04 Brunhilda’s Birthday (BOI13_brunhilda) C++14
17.619 / 100
1000 ms 40244 KB
    #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 ;
    }

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d" , &n , &q) ;
         ~~~~~^~~~~~~~~~~~~~~~~~~
brunhilda.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d" , &arr[i]) ;
             ~~~~~^~~~~~~~~~~~~~~~
brunhilda.cpp:49:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d" , &x) ;
             ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 217 ms 39544 KB Output is correct
2 Execution timed out 1080 ms 25932 KB Time limit exceeded
3 Correct 842 ms 39544 KB Output is correct
4 Correct 244 ms 39544 KB Output is correct
5 Correct 556 ms 39672 KB Output is correct
6 Correct 217 ms 39444 KB Output is correct
7 Correct 841 ms 39544 KB Output is correct
8 Execution timed out 1090 ms 35576 KB Time limit exceeded
9 Execution timed out 1085 ms 19848 KB Time limit exceeded
10 Execution timed out 1077 ms 15660 KB Time limit exceeded
11 Execution timed out 1087 ms 21772 KB Time limit exceeded
12 Correct 180 ms 39500 KB Output is correct
13 Execution timed out 1083 ms 6760 KB Time limit exceeded
14 Execution timed out 1080 ms 6520 KB Time limit exceeded
15 Execution timed out 1086 ms 24952 KB Time limit exceeded
16 Execution timed out 1059 ms 25716 KB Time limit exceeded
17 Correct 764 ms 39584 KB Output is correct
18 Correct 245 ms 39544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 860 ms 40244 KB Output is correct
2 Execution timed out 1085 ms 35172 KB Time limit exceeded
3 Execution timed out 1052 ms 7656 KB Time limit exceeded
4 Execution timed out 1087 ms 25720 KB Time limit exceeded
5 Execution timed out 1076 ms 10096 KB Time limit exceeded
6 Execution timed out 1086 ms 26748 KB Time limit exceeded
7 Correct 854 ms 40220 KB Output is correct
8 Execution timed out 1073 ms 30440 KB Time limit exceeded
9 Execution timed out 1078 ms 9604 KB Time limit exceeded
10 Execution timed out 1083 ms 7656 KB Time limit exceeded
11 Execution timed out 1087 ms 6400 KB Time limit exceeded
12 Execution timed out 1088 ms 12548 KB Time limit exceeded
13 Correct 729 ms 39800 KB Output is correct
14 Execution timed out 1089 ms 25684 KB Time limit exceeded
15 Execution timed out 1079 ms 7536 KB Time limit exceeded
16 Execution timed out 1081 ms 35072 KB Time limit exceeded
17 Execution timed out 1087 ms 6136 KB Time limit exceeded
18 Execution timed out 1086 ms 10552 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1063 ms 7432 KB Time limit exceeded
2 Execution timed out 1080 ms 6688 KB Time limit exceeded
3 Execution timed out 1072 ms 6656 KB Time limit exceeded
4 Execution timed out 1077 ms 10924 KB Time limit exceeded
5 Execution timed out 1086 ms 30568 KB Time limit exceeded
6 Execution timed out 1075 ms 7104 KB Time limit exceeded
7 Execution timed out 1092 ms 13420 KB Time limit exceeded
8 Execution timed out 1081 ms 7628 KB Time limit exceeded
9 Execution timed out 1087 ms 7536 KB Time limit exceeded
10 Execution timed out 1077 ms 10724 KB Time limit exceeded
11 Execution timed out 1079 ms 14968 KB Time limit exceeded
12 Execution timed out 1068 ms 7288 KB Time limit exceeded
13 Execution timed out 1068 ms 6536 KB Time limit exceeded
14 Execution timed out 1086 ms 13304 KB Time limit exceeded
15 Execution timed out 1075 ms 6264 KB Time limit exceeded
16 Execution timed out 1081 ms 5884 KB Time limit exceeded
17 Execution timed out 1086 ms 8988 KB Time limit exceeded
18 Execution timed out 1086 ms 6972 KB Time limit exceeded
19 Execution timed out 1081 ms 35960 KB Time limit exceeded
20 Execution timed out 1083 ms 6688 KB Time limit exceeded
21 Execution timed out 1086 ms 9592 KB Time limit exceeded
22 Execution timed out 1077 ms 9396 KB Time limit exceeded
23 Execution timed out 1081 ms 27372 KB Time limit exceeded
24 Correct 678 ms 39860 KB Output is correct
25 Execution timed out 1061 ms 10228 KB Time limit exceeded
26 Execution timed out 1073 ms 10872 KB Time limit exceeded
27 Execution timed out 1079 ms 9020 KB Time limit exceeded
28 Execution timed out 1063 ms 40056 KB Time limit exceeded
29 Execution timed out 1075 ms 10988 KB Time limit exceeded
30 Execution timed out 1080 ms 10320 KB Time limit exceeded
31 Execution timed out 1076 ms 29460 KB Time limit exceeded
32 Execution timed out 1088 ms 21836 KB Time limit exceeded
33 Correct 383 ms 39932 KB Output is correct
34 Execution timed out 1075 ms 13040 KB Time limit exceeded
35 Execution timed out 1090 ms 33272 KB Time limit exceeded
36 Execution timed out 1075 ms 8812 KB Time limit exceeded
37 Execution timed out 1085 ms 31208 KB Time limit exceeded
38 Execution timed out 1071 ms 7108 KB Time limit exceeded
39 Correct 999 ms 40096 KB Output is correct
40 Execution timed out 1075 ms 8568 KB Time limit exceeded
41 Execution timed out 1075 ms 12560 KB Time limit exceeded
42 Execution timed out 1077 ms 5780 KB Time limit exceeded