Submission #575662

# Submission time Handle Problem Language Result Execution time Memory
575662 2022-06-11T07:31:46 Z ktkerem Brunhilda’s Birthday (BOI13_brunhilda) C++17
97.7778 / 100
354 ms 88324 KB
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
/*#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
template<class T>
using oset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
/**/
//typedef int ll;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 vll;
typedef unsigned __int128 uvll;
ll _i=0;
#define ffn(x) _i=x
#define llll std::pair<ll , ll>
#define stitr set<ll>::iterator
#define fora(y,x) for(ll y=_i;x>y;y++)
#define pb push_back
#define pf push_front
#define halo cout << "hello\n"
#define fi first
#define sec second
#define all(a) a.begin() , a.end()
const ll limit = 1e9 + 7; 
const ll ous = 1e7 + 1e6 + 7;
const ll dx[4] = {1 , 0 , 0 , -1} , dy[4] = {0,1,-1,0};
void solve(){
    ll n , q;std::cin >> n >> q;
    ll dp[ous];memset(dp , 0 , sizeof(dp));
    fora(i , n){
        ll x;std::cin >> x;
        for(ll j = x-1;ous > j;j+=x){
            dp[j] = std::max(dp[j] , x-1);
        }
    }
    for(ll i = ous - 2;i>=0;i--){
        dp[i] = std::max(dp[i] , dp[i + 1] - 1);
    }
    for(ll i = 1;ous - 2 > i ; i++){
        if(dp[i] > 0){
            dp[i] = dp[i - dp[i]] + 1;
        }
        else{
            dp[i] = limit;
        }
    }
    fora(i , q){
        ll x;std::cin >> x;
        if(dp[x] == limit){
            std::cout << "oo" << "\n";
        }
        else{
            std::cout << dp[x] << "\n";
        }
    }
    return;/**/
}
signed main(){
    std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);
    ll t=1;
    //std::cin >> t;
    ll o = 1;
    while(t--){ 
        //cout << "Case " << o++ << ":\n";
        solve();
    }
    return 0; 
}

Compilation message

brunhilda.cpp:12:1: warning: "/*" within comment [-Wcomment]
   12 | /**/
      |  
brunhilda.cpp: In function 'int main()':
brunhilda.cpp:67:8: warning: unused variable 'o' [-Wunused-variable]
   67 |     ll o = 1;
      |        ^
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 86424 KB Output isn't correct
2 Correct 110 ms 86408 KB Output is correct
3 Correct 100 ms 86408 KB Output is correct
4 Correct 86 ms 86604 KB Output is correct
5 Correct 96 ms 86404 KB Output is correct
6 Incorrect 85 ms 86404 KB Output isn't correct
7 Correct 98 ms 86284 KB Output is correct
8 Correct 107 ms 86304 KB Output is correct
9 Correct 129 ms 86408 KB Output is correct
10 Correct 165 ms 86348 KB Output is correct
11 Correct 136 ms 86344 KB Output is correct
12 Correct 77 ms 86408 KB Output is correct
13 Correct 236 ms 86540 KB Output is correct
14 Correct 234 ms 86456 KB Output is correct
15 Correct 118 ms 86404 KB Output is correct
16 Correct 110 ms 86408 KB Output is correct
17 Correct 103 ms 86580 KB Output is correct
18 Correct 82 ms 86476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 86448 KB Output is correct
2 Correct 110 ms 87076 KB Output is correct
3 Correct 291 ms 86836 KB Output is correct
4 Correct 117 ms 86428 KB Output is correct
5 Correct 215 ms 86712 KB Output is correct
6 Correct 103 ms 86360 KB Output is correct
7 Correct 95 ms 86584 KB Output is correct
8 Correct 128 ms 86404 KB Output is correct
9 Correct 230 ms 86800 KB Output is correct
10 Correct 282 ms 86860 KB Output is correct
11 Correct 283 ms 86576 KB Output is correct
12 Correct 155 ms 86348 KB Output is correct
13 Correct 89 ms 86360 KB Output is correct
14 Correct 118 ms 86428 KB Output is correct
15 Correct 236 ms 86680 KB Output is correct
16 Correct 109 ms 87100 KB Output is correct
17 Correct 233 ms 86432 KB Output is correct
18 Correct 254 ms 87152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 245 ms 87092 KB Output is correct
2 Correct 295 ms 86936 KB Output is correct
3 Correct 302 ms 87208 KB Output is correct
4 Correct 183 ms 87316 KB Output is correct
5 Correct 149 ms 88324 KB Output is correct
6 Correct 244 ms 87368 KB Output is correct
7 Correct 203 ms 87672 KB Output is correct
8 Correct 256 ms 87036 KB Output is correct
9 Correct 246 ms 87096 KB Output is correct
10 Correct 187 ms 86452 KB Output is correct
11 Correct 155 ms 86668 KB Output is correct
12 Correct 222 ms 86584 KB Output is correct
13 Correct 288 ms 87520 KB Output is correct
14 Correct 177 ms 87604 KB Output is correct
15 Correct 227 ms 86604 KB Output is correct
16 Correct 288 ms 86584 KB Output is correct
17 Correct 236 ms 86864 KB Output is correct
18 Correct 287 ms 86940 KB Output is correct
19 Correct 113 ms 86648 KB Output is correct
20 Correct 292 ms 87220 KB Output is correct
21 Correct 193 ms 87688 KB Output is correct
22 Correct 306 ms 88012 KB Output is correct
23 Correct 137 ms 87600 KB Output is correct
24 Correct 111 ms 87348 KB Output is correct
25 Correct 193 ms 87408 KB Output is correct
26 Correct 192 ms 87244 KB Output is correct
27 Correct 354 ms 87608 KB Output is correct
28 Correct 113 ms 87500 KB Output is correct
29 Correct 284 ms 87988 KB Output is correct
30 Correct 251 ms 87868 KB Output is correct
31 Correct 131 ms 87244 KB Output is correct
32 Correct 147 ms 87372 KB Output is correct
33 Correct 103 ms 87356 KB Output is correct
34 Correct 217 ms 87672 KB Output is correct
35 Correct 118 ms 87476 KB Output is correct
36 Correct 302 ms 87932 KB Output is correct
37 Correct 141 ms 88116 KB Output is correct
38 Correct 244 ms 87416 KB Output is correct
39 Correct 129 ms 87372 KB Output is correct
40 Correct 206 ms 87412 KB Output is correct
41 Correct 196 ms 87568 KB Output is correct
42 Correct 301 ms 87540 KB Output is correct