Submission #421060

# Submission time Handle Problem Language Result Execution time Memory
421060 2021-06-08T17:00:07 Z LouayFarah Horses (IOI15_horses) C++14
17 / 100
83 ms 96200 KB
#include "bits/stdc++.h"
#include "horses.h"
using namespace std;
 
const int MOD = 1e9+7;

int n;
vector<int> x, y;
vector<vector<int>> dp(1001, vector<int>(10001, -1));

int solve(int h, int i, int curr)
{
    if(i==n)
    {
        return dp[h][curr] = curr;
    }

    if(h==0)
        return dp[h][curr] = curr;

    if(dp[h][curr]!=-1)
        return dp[h][curr];

    int t = h*x[i];

    int maxi = curr;
    int j = 0;
    maxi = max(maxi, solve(t - j, i+1, (curr%MOD + ((j%MOD)*(y[i])%MOD)%MOD))%MOD);

    j = t;
    maxi = max(maxi, solve(t - j, i+1, (curr%MOD + ((j%MOD)*(y[i])%MOD)%MOD))%MOD);

    j = t-1;
    maxi = max(maxi, solve(t - j, i+1, (curr%MOD + ((j%MOD)*(y[i])%MOD)%MOD))%MOD);

    j = 1;
    maxi = max(maxi, solve(t - j, i+1, (curr%MOD + ((j%MOD)*(y[i])%MOD)%MOD))%MOD);

    return maxi;
}

int init(int N, int X[], int Y[])
{
    n = N;
    x.assign(n, 0);
    y.assign(n, 0);

    for(int i = 0; i<n; i++)
    {
        x[i] = X[i];
        y[i] = Y[i];
    }

    int res = solve(1, 0, 0);
    return res;
}

int updateX(int pos, int val)
{
    x[pos] = val;
    int res = solve(1, 0, 0);
    return res;
}

int updateY(int pos, int val)
{
    y[pos] = val;
    int res = solve(1, 0, 0);
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 22 ms 39544 KB Output is correct
2 Correct 20 ms 39500 KB Output is correct
3 Correct 20 ms 39500 KB Output is correct
4 Correct 21 ms 39500 KB Output is correct
5 Correct 21 ms 39476 KB Output is correct
6 Correct 22 ms 39516 KB Output is correct
7 Correct 21 ms 39472 KB Output is correct
8 Correct 21 ms 39424 KB Output is correct
9 Correct 20 ms 39488 KB Output is correct
10 Correct 24 ms 39488 KB Output is correct
11 Correct 20 ms 39500 KB Output is correct
12 Correct 21 ms 39400 KB Output is correct
13 Correct 22 ms 39436 KB Output is correct
14 Correct 20 ms 39500 KB Output is correct
15 Correct 20 ms 39544 KB Output is correct
16 Correct 20 ms 39500 KB Output is correct
17 Correct 21 ms 39504 KB Output is correct
18 Correct 21 ms 39544 KB Output is correct
19 Correct 21 ms 39568 KB Output is correct
20 Correct 22 ms 39420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 39484 KB Output is correct
2 Correct 20 ms 39512 KB Output is correct
3 Correct 26 ms 39540 KB Output is correct
4 Correct 23 ms 39500 KB Output is correct
5 Correct 22 ms 39524 KB Output is correct
6 Correct 22 ms 39500 KB Output is correct
7 Correct 20 ms 39544 KB Output is correct
8 Correct 21 ms 39500 KB Output is correct
9 Correct 24 ms 39524 KB Output is correct
10 Correct 21 ms 39488 KB Output is correct
11 Correct 21 ms 39480 KB Output is correct
12 Correct 21 ms 39512 KB Output is correct
13 Correct 21 ms 39432 KB Output is correct
14 Correct 20 ms 39492 KB Output is correct
15 Correct 21 ms 39536 KB Output is correct
16 Correct 21 ms 39544 KB Output is correct
17 Correct 22 ms 39508 KB Output is correct
18 Correct 20 ms 39496 KB Output is correct
19 Correct 24 ms 39532 KB Output is correct
20 Correct 22 ms 39500 KB Output is correct
21 Runtime error 67 ms 79880 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 83 ms 96200 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 39504 KB Output is correct
2 Correct 22 ms 39492 KB Output is correct
3 Correct 24 ms 39500 KB Output is correct
4 Correct 21 ms 39492 KB Output is correct
5 Correct 20 ms 39512 KB Output is correct
6 Correct 22 ms 39548 KB Output is correct
7 Correct 22 ms 39452 KB Output is correct
8 Correct 21 ms 39512 KB Output is correct
9 Correct 21 ms 39452 KB Output is correct
10 Correct 20 ms 39500 KB Output is correct
11 Correct 26 ms 39536 KB Output is correct
12 Correct 20 ms 39500 KB Output is correct
13 Correct 21 ms 39484 KB Output is correct
14 Correct 21 ms 39528 KB Output is correct
15 Correct 21 ms 39488 KB Output is correct
16 Correct 19 ms 39500 KB Output is correct
17 Correct 21 ms 39444 KB Output is correct
18 Correct 22 ms 39512 KB Output is correct
19 Correct 22 ms 39436 KB Output is correct
20 Correct 21 ms 39448 KB Output is correct
21 Runtime error 64 ms 79940 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 39492 KB Output is correct
2 Correct 21 ms 39500 KB Output is correct
3 Correct 22 ms 39436 KB Output is correct
4 Correct 21 ms 39488 KB Output is correct
5 Correct 20 ms 39440 KB Output is correct
6 Correct 21 ms 39544 KB Output is correct
7 Correct 21 ms 39520 KB Output is correct
8 Correct 21 ms 39508 KB Output is correct
9 Correct 21 ms 39544 KB Output is correct
10 Correct 20 ms 39448 KB Output is correct
11 Correct 21 ms 39504 KB Output is correct
12 Correct 24 ms 39472 KB Output is correct
13 Correct 21 ms 39500 KB Output is correct
14 Correct 21 ms 39436 KB Output is correct
15 Correct 20 ms 39544 KB Output is correct
16 Correct 21 ms 39544 KB Output is correct
17 Correct 19 ms 39512 KB Output is correct
18 Correct 21 ms 39436 KB Output is correct
19 Correct 22 ms 39464 KB Output is correct
20 Correct 22 ms 39500 KB Output is correct
21 Runtime error 62 ms 79952 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -