Submission #548367

# Submission time Handle Problem Language Result Execution time Memory
548367 2022-04-13T06:54:27 Z Amylopectin Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
35 ms 2752 KB
#include <iostream>
#include <stdio.h>

using namespace std;
const long long mxn = 2e5 + 10,mxm = 1e7 + 10;
long long pri[mxn] = {},nli[mxm] = {};
long long fima(long long l,long long r)
{
    if(l > r)
        return l;
    return r;
}
int main()
{
    long long i,j,n,m,cou = 0,cn,fn,cma,mu = 1,cl,cr,mid,p;
    scanf("%lld %lld",&n,&m);
    for(i=0; i<n; i++)
    {
        scanf("%lld",&pri[i]);
        mu *= pri[i];
        if(mu > 10000000)
            mu = 10000001;
    }
    nli[0] = 0;
    for(i=1; 1; i++)
    {
        cma = nli[i-1];
        for(j=n-1; j>=0; j--)
        {
            if(pri[j] <= cma - nli[i-1])
                break;
            cn = pri[j] - (nli[i-1] % pri[j]) - 1 + nli[i-1];
            if(cn > cma)
            {
                cma = cn;
                fn = pri[j];
            }

//            cma = fima(cma,);
        }
        nli[i] = cma;
//        if(i<100)
//            printf("%lld %lld %lld\n",i,fn,cma);
        if(cma >= mu-1)
            break;
    }
    p = i;
//    for(j=0; j<=i; j++)
//    {
//        printf("%d\n",nli[j]);
//    }
    for(i=0; i<m; i++)
    {
        scanf("%lld",&cn);
        if(cn >= mu)
        {
            printf("oo\n");
            continue;
        }
        cl = 0;
        cr = p;
        while(cl < cr)
        {
            mid = (cl+cr)/2;
            if(nli[mid] >= cn)
            {
                cr = mid;
            }
            else
                cl = mid+1;
        }
        printf("%lld\n",cl);
    }
    return 0;
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:15:23: warning: unused variable 'cou' [-Wunused-variable]
   15 |     long long i,j,n,m,cou = 0,cn,fn,cma,mu = 1,cl,cr,mid,p;
      |                       ^~~
brunhilda.cpp:15:34: warning: variable 'fn' set but not used [-Wunused-but-set-variable]
   15 |     long long i,j,n,m,cou = 0,cn,fn,cma,mu = 1,cl,cr,mid,p;
      |                                  ^~
brunhilda.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%lld %lld",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
brunhilda.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf("%lld",&pri[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~
brunhilda.cpp:54:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         scanf("%lld",&cn);
      |         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 8 ms 1576 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 9 ms 2400 KB Output is correct
10 Correct 4 ms 980 KB Output is correct
11 Correct 4 ms 952 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 468 KB Output is correct
16 Correct 2 ms 436 KB Output is correct
17 Correct 4 ms 468 KB Output is correct
18 Correct 3 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 9 ms 1620 KB Output is correct
3 Correct 7 ms 1236 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 5 ms 976 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 8 ms 1364 KB Output is correct
10 Correct 7 ms 1236 KB Output is correct
11 Correct 5 ms 840 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 5 ms 848 KB Output is correct
16 Correct 10 ms 1612 KB Output is correct
17 Correct 1 ms 316 KB Output is correct
18 Correct 10 ms 1704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1364 KB Output is correct
2 Correct 11 ms 1296 KB Output is correct
3 Correct 18 ms 1540 KB Output is correct
4 Correct 22 ms 1228 KB Output is correct
5 Correct 35 ms 2720 KB Output is correct
6 Correct 26 ms 1320 KB Output is correct
7 Correct 22 ms 2228 KB Output is correct
8 Correct 15 ms 1332 KB Output is correct
9 Correct 17 ms 1336 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 7 ms 580 KB Output is correct
12 Correct 7 ms 596 KB Output is correct
13 Correct 23 ms 1724 KB Output is correct
14 Correct 28 ms 2200 KB Output is correct
15 Correct 8 ms 600 KB Output is correct
16 Correct 6 ms 640 KB Output is correct
17 Correct 7 ms 1084 KB Output is correct
18 Correct 11 ms 1228 KB Output is correct
19 Correct 6 ms 596 KB Output is correct
20 Correct 18 ms 1604 KB Output is correct
21 Correct 25 ms 1736 KB Output is correct
22 Correct 32 ms 2660 KB Output is correct
23 Correct 25 ms 1724 KB Output is correct
24 Correct 24 ms 1204 KB Output is correct
25 Correct 25 ms 1372 KB Output is correct
26 Correct 22 ms 1248 KB Output is correct
27 Correct 22 ms 2240 KB Output is correct
28 Correct 22 ms 1364 KB Output is correct
29 Correct 31 ms 2752 KB Output is correct
30 Correct 32 ms 2388 KB Output is correct
31 Correct 21 ms 1144 KB Output is correct
32 Correct 24 ms 1220 KB Output is correct
33 Correct 22 ms 1228 KB Output is correct
34 Correct 21 ms 2272 KB Output is correct
35 Correct 23 ms 1336 KB Output is correct
36 Correct 31 ms 2520 KB Output is correct
37 Correct 32 ms 2732 KB Output is correct
38 Correct 25 ms 1300 KB Output is correct
39 Correct 25 ms 1316 KB Output is correct
40 Correct 24 ms 1276 KB Output is correct
41 Correct 22 ms 2340 KB Output is correct
42 Correct 23 ms 1472 KB Output is correct