Submission #493577

# Submission time Handle Problem Language Result Execution time Memory
493577 2021-12-12T08:48:11 Z reni Schools (IZhO13_school) C++14
15 / 100
2000 ms 27148 KB
#include<iostream>
using namespace std;
long long a[10000000], b[1000003], dp[1000000][3],n;

long long rec(long long pos,long long m,long long s)
{
    if(pos==n)return 0;
    long long maxi=0;

    if(m>0)maxi=max(maxi, rec(pos+1,m-1,s)+a[pos]);
    if(s>0)maxi=max(maxi, rec(pos+1,m,s-1)+b[pos]);
    maxi=max(maxi, rec(pos+1,m,s));

    return maxi;

}
int main()
{
    long long br=0,m,s,i,j;

    cin>>n>>m>>s;

    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    cout<<rec(0,m,s)<<endl;


}


Compilation message

school.cpp: In function 'int main()':
school.cpp:19:15: warning: unused variable 'br' [-Wunused-variable]
   19 |     long long br=0,m,s,i,j;
      |               ^~
school.cpp:19:26: warning: unused variable 'j' [-Wunused-variable]
   19 |     long long br=0,m,s,i,j;
      |                          ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Execution timed out 2066 ms 204 KB Time limit exceeded
5 Execution timed out 2080 ms 204 KB Time limit exceeded
6 Execution timed out 2094 ms 204 KB Time limit exceeded
7 Execution timed out 2091 ms 588 KB Time limit exceeded
8 Execution timed out 2097 ms 588 KB Time limit exceeded
9 Execution timed out 2094 ms 716 KB Time limit exceeded
10 Execution timed out 2071 ms 716 KB Time limit exceeded
11 Execution timed out 2081 ms 716 KB Time limit exceeded
12 Execution timed out 2089 ms 696 KB Time limit exceeded
13 Execution timed out 2082 ms 3404 KB Time limit exceeded
14 Execution timed out 2082 ms 7204 KB Time limit exceeded
15 Execution timed out 2071 ms 14428 KB Time limit exceeded
16 Execution timed out 2056 ms 16248 KB Time limit exceeded
17 Execution timed out 2087 ms 19908 KB Time limit exceeded
18 Execution timed out 2084 ms 21820 KB Time limit exceeded
19 Execution timed out 2092 ms 23652 KB Time limit exceeded
20 Execution timed out 2072 ms 27148 KB Time limit exceeded