Submission #282285

# Submission time Handle Problem Language Result Execution time Memory
282285 2020-08-24T08:45:00 Z MKopchev Sparklers (JOI17_sparklers) C++14
50 / 100
49 ms 4668 KB
#include<bits/stdc++.h>
using namespace std;

const int nmax=1e3+42,inf=1e9;

int n,k,t,inp[nmax];

int mem[nmax][nmax];

int cur_v;

int ask(int l,int r)
{
    if(k<l||k>r)return 0;

    if(l==r)return 1;
    if(mem[l][r]!=-1)return mem[l][r];

    if(inp[r]-inp[l]<=2LL*(r-l)*t*cur_v)
    {
        if(ask(l,r-1))mem[l][r]=1;
        else if(ask(l+1,r))mem[l][r]=1;
        else mem[l][r]=0;
    }
    else mem[l][r]=0;

    //cout<<l<<" "<<r<<" -> "<<mem[l][r]<<endl;

    return mem[l][r];
}
bool test(int v)
{
    //cout<<"v= "<<v<<endl;

    memset(mem,-1,sizeof(mem));

    cur_v=v;

    return ask(1,n);
}
int main()
{
    scanf("%i%i%i",&n,&k,&t);

    for(int i=1;i<=n;i++)scanf("%i",&inp[i]);

    int ok=inf/t+1,not_ok=-1;

    while(ok-not_ok>1)
    {
        int av=(ok+not_ok)/2;

        if(test(av))ok=av;
        else not_ok=av;
    }
    printf("%i\n",ok);
    return 0;
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   43 |     scanf("%i%i%i",&n,&k,&t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
sparklers.cpp:45:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |     for(int i=1;i<=n;i++)scanf("%i",&inp[i]);
      |                          ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 4608 KB Output is correct
2 Correct 9 ms 4608 KB Output is correct
3 Correct 10 ms 4608 KB Output is correct
4 Correct 11 ms 4628 KB Output is correct
5 Correct 8 ms 4608 KB Output is correct
6 Correct 9 ms 4608 KB Output is correct
7 Correct 8 ms 4608 KB Output is correct
8 Correct 8 ms 4608 KB Output is correct
9 Correct 8 ms 4608 KB Output is correct
10 Correct 9 ms 4608 KB Output is correct
11 Correct 11 ms 4608 KB Output is correct
12 Correct 8 ms 4608 KB Output is correct
13 Correct 9 ms 4584 KB Output is correct
14 Correct 8 ms 4608 KB Output is correct
15 Correct 9 ms 4608 KB Output is correct
16 Correct 8 ms 4608 KB Output is correct
17 Correct 9 ms 4608 KB Output is correct
18 Correct 8 ms 4608 KB Output is correct
19 Correct 8 ms 4608 KB Output is correct
20 Correct 9 ms 4608 KB Output is correct
21 Correct 9 ms 4608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 4608 KB Output is correct
2 Correct 9 ms 4608 KB Output is correct
3 Correct 10 ms 4608 KB Output is correct
4 Correct 11 ms 4628 KB Output is correct
5 Correct 8 ms 4608 KB Output is correct
6 Correct 9 ms 4608 KB Output is correct
7 Correct 8 ms 4608 KB Output is correct
8 Correct 8 ms 4608 KB Output is correct
9 Correct 8 ms 4608 KB Output is correct
10 Correct 9 ms 4608 KB Output is correct
11 Correct 11 ms 4608 KB Output is correct
12 Correct 8 ms 4608 KB Output is correct
13 Correct 9 ms 4584 KB Output is correct
14 Correct 8 ms 4608 KB Output is correct
15 Correct 9 ms 4608 KB Output is correct
16 Correct 8 ms 4608 KB Output is correct
17 Correct 9 ms 4608 KB Output is correct
18 Correct 8 ms 4608 KB Output is correct
19 Correct 8 ms 4608 KB Output is correct
20 Correct 9 ms 4608 KB Output is correct
21 Correct 9 ms 4608 KB Output is correct
22 Correct 24 ms 4608 KB Output is correct
23 Correct 8 ms 4608 KB Output is correct
24 Correct 17 ms 4608 KB Output is correct
25 Correct 11 ms 4608 KB Output is correct
26 Correct 9 ms 4608 KB Output is correct
27 Correct 9 ms 4608 KB Output is correct
28 Correct 47 ms 4608 KB Output is correct
29 Correct 37 ms 4668 KB Output is correct
30 Correct 35 ms 4608 KB Output is correct
31 Correct 33 ms 4608 KB Output is correct
32 Correct 11 ms 4608 KB Output is correct
33 Correct 34 ms 4608 KB Output is correct
34 Correct 20 ms 4608 KB Output is correct
35 Correct 11 ms 4608 KB Output is correct
36 Correct 17 ms 4608 KB Output is correct
37 Correct 17 ms 4608 KB Output is correct
38 Correct 49 ms 4660 KB Output is correct
39 Correct 15 ms 4608 KB Output is correct
40 Correct 9 ms 4608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 4608 KB Output is correct
2 Correct 9 ms 4608 KB Output is correct
3 Correct 10 ms 4608 KB Output is correct
4 Correct 11 ms 4628 KB Output is correct
5 Correct 8 ms 4608 KB Output is correct
6 Correct 9 ms 4608 KB Output is correct
7 Correct 8 ms 4608 KB Output is correct
8 Correct 8 ms 4608 KB Output is correct
9 Correct 8 ms 4608 KB Output is correct
10 Correct 9 ms 4608 KB Output is correct
11 Correct 11 ms 4608 KB Output is correct
12 Correct 8 ms 4608 KB Output is correct
13 Correct 9 ms 4584 KB Output is correct
14 Correct 8 ms 4608 KB Output is correct
15 Correct 9 ms 4608 KB Output is correct
16 Correct 8 ms 4608 KB Output is correct
17 Correct 9 ms 4608 KB Output is correct
18 Correct 8 ms 4608 KB Output is correct
19 Correct 8 ms 4608 KB Output is correct
20 Correct 9 ms 4608 KB Output is correct
21 Correct 9 ms 4608 KB Output is correct
22 Correct 24 ms 4608 KB Output is correct
23 Correct 8 ms 4608 KB Output is correct
24 Correct 17 ms 4608 KB Output is correct
25 Correct 11 ms 4608 KB Output is correct
26 Correct 9 ms 4608 KB Output is correct
27 Correct 9 ms 4608 KB Output is correct
28 Correct 47 ms 4608 KB Output is correct
29 Correct 37 ms 4668 KB Output is correct
30 Correct 35 ms 4608 KB Output is correct
31 Correct 33 ms 4608 KB Output is correct
32 Correct 11 ms 4608 KB Output is correct
33 Correct 34 ms 4608 KB Output is correct
34 Correct 20 ms 4608 KB Output is correct
35 Correct 11 ms 4608 KB Output is correct
36 Correct 17 ms 4608 KB Output is correct
37 Correct 17 ms 4608 KB Output is correct
38 Correct 49 ms 4660 KB Output is correct
39 Correct 15 ms 4608 KB Output is correct
40 Correct 9 ms 4608 KB Output is correct
41 Execution timed out 2 ms 512 KB Time limit exceeded (wall clock)
42 Halted 0 ms 0 KB -