Submission #155742

# Submission time Handle Problem Language Result Execution time Memory
155742 2019-09-30T07:51:21 Z puppies_and_rainbows Brunhilda’s Birthday (BOI13_brunhilda) C++14
20.1587 / 100
1000 ms 79636 KB
#include <bits/stdc++.h>

#pragma GCC optimize("O3")
using namespace std;

int n, q;
int tobest[10000005];
int last[10000005];
int ans[10000005];
int ask[100005], p[100005];
int maxsolved=0, maxask=0;
bool used[10000005];
void eras()
{
    for(int i=1; i<=n; i++)
    {
        if(p[i]!=p[i-1])
        {
            for(int j=0; j<=maxask; j+=p[i])
            {
                last[j]=max(last[j], j+p[i]-1);
            }
        }
    }
}

void solve()
{
    int j=0;
    tobest[0]=p[n]-1;
    for(int i=0; i<=10000000; i++)
    {
        if(tobest[i]==0) return;
        if(i>0) j=tobest[j-1]+1;
        for(int k=j; k<=tobest[i]; k++)
        {
            if(k>maxask) return;
            tobest[i+1]=max(tobest[i+1], last[k]);
            ans[k]=i;
        }
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>q;
    for(int i=1; i<=n; i++)
    {
        cin>>p[i];
    }
    sort(p+1, p+n+1);
    for(int i=1; i<=q; i++)
    {
        cin>>ask[i];
        maxask=max(maxask, ask[i]);
    }
    eras();
    solve();
    // for(int i=0; i<=5; i++)
    // {
    //     cout<<tobest[i]<<endl;
    // }
    for(int i=1; i<=q; i++)
    {
        if(ans[ask[i]]==0) cout<<"oo\n";
        else cout<<ans[i]+1<<"\n";
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Incorrect 4 ms 504 KB Output isn't correct
4 Incorrect 4 ms 504 KB Output isn't correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Incorrect 3 ms 504 KB Output isn't correct
7 Incorrect 4 ms 376 KB Output isn't correct
8 Incorrect 4 ms 376 KB Output isn't correct
9 Incorrect 2 ms 376 KB Output isn't correct
10 Incorrect 2 ms 376 KB Output isn't correct
11 Incorrect 3 ms 376 KB Output isn't correct
12 Incorrect 2 ms 376 KB Output isn't correct
13 Incorrect 2 ms 504 KB Output isn't correct
14 Incorrect 4 ms 504 KB Output isn't correct
15 Incorrect 2 ms 376 KB Output isn't correct
16 Incorrect 2 ms 376 KB Output isn't correct
17 Incorrect 4 ms 504 KB Output isn't correct
18 Incorrect 4 ms 504 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 172 ms 77836 KB Output is correct
2 Correct 124 ms 71136 KB Output is correct
3 Incorrect 129 ms 37624 KB Output isn't correct
4 Correct 608 ms 71288 KB Output is correct
5 Incorrect 46 ms 20856 KB Output isn't correct
6 Correct 112 ms 27512 KB Output is correct
7 Correct 170 ms 77788 KB Output is correct
8 Correct 275 ms 29732 KB Output is correct
9 Correct 51 ms 20984 KB Output is correct
10 Incorrect 114 ms 37496 KB Output isn't correct
11 Correct 369 ms 78968 KB Output is correct
12 Incorrect 973 ms 67396 KB Output isn't correct
13 Correct 208 ms 77972 KB Output is correct
14 Correct 557 ms 71220 KB Output is correct
15 Correct 61 ms 25592 KB Output is correct
16 Correct 139 ms 71160 KB Output is correct
17 Execution timed out 1054 ms 67452 KB Time limit exceeded
18 Correct 266 ms 79044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 321 ms 79184 KB Output isn't correct
2 Incorrect 438 ms 78980 KB Output isn't correct
3 Incorrect 231 ms 56200 KB Output isn't correct
4 Incorrect 748 ms 79376 KB Output isn't correct
5 Incorrect 169 ms 79636 KB Output isn't correct
6 Incorrect 672 ms 79464 KB Output isn't correct
7 Correct 165 ms 56312 KB Output is correct
8 Incorrect 302 ms 79096 KB Output isn't correct
9 Incorrect 329 ms 79124 KB Output isn't correct
10 Incorrect 762 ms 78712 KB Output isn't correct
11 Incorrect 789 ms 78924 KB Output isn't correct
12 Incorrect 942 ms 79080 KB Output isn't correct
13 Correct 198 ms 40984 KB Output is correct
14 Execution timed out 1074 ms 26616 KB Time limit exceeded
15 Incorrect 973 ms 78996 KB Output isn't correct
16 Incorrect 949 ms 78984 KB Output isn't correct
17 Incorrect 310 ms 78968 KB Output isn't correct
18 Incorrect 400 ms 79096 KB Output isn't correct
19 Incorrect 203 ms 78804 KB Output isn't correct
20 Incorrect 236 ms 56284 KB Output isn't correct
21 Execution timed out 1078 ms 45052 KB Time limit exceeded
22 Incorrect 462 ms 79548 KB Output isn't correct
23 Incorrect 230 ms 79588 KB Output isn't correct
24 Incorrect 770 ms 79568 KB Output isn't correct
25 Execution timed out 1069 ms 74568 KB Time limit exceeded
26 Incorrect 755 ms 79304 KB Output isn't correct
27 Correct 269 ms 56312 KB Output is correct
28 Incorrect 664 ms 79484 KB Output isn't correct
29 Incorrect 347 ms 79608 KB Output isn't correct
30 Incorrect 334 ms 79524 KB Output isn't correct
31 Incorrect 332 ms 79264 KB Output isn't correct
32 Incorrect 794 ms 79352 KB Output isn't correct
33 Incorrect 397 ms 79184 KB Output isn't correct
34 Correct 190 ms 56284 KB Output is correct
35 Incorrect 603 ms 79312 KB Output isn't correct
36 Incorrect 377 ms 79572 KB Output isn't correct
37 Incorrect 168 ms 79552 KB Output isn't correct
38 Incorrect 717 ms 79284 KB Output isn't correct
39 Incorrect 638 ms 79324 KB Output isn't correct
40 Incorrect 525 ms 79336 KB Output isn't correct
41 Incorrect 153 ms 56388 KB Output isn't correct
42 Execution timed out 1075 ms 67628 KB Time limit exceeded