Submission #288452

# Submission time Handle Problem Language Result Execution time Memory
288452 2020-09-01T13:52:08 Z AaronNaidu Horses (IOI15_horses) C++14
34 / 100
1500 ms 12252 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

ll mod = 1000000007;
ll n;
vector<ll> x, y;

int solveProblem() {
    int maxInd = -1;
    ld maxAns = -1;
    ld currAns = 0;
    for (int i = 0; i < n; i++)
    {
        currAns += log10(x[i]);
        currAns += log10(y[i]);
        if (currAns > maxAns)
        {
            maxAns = currAns;
            maxInd = i;
        }
        currAns -= log10(y[i]);
    }
    ll finAns = 1;
    for (int i = 0; i < maxInd; i++)
    {
        finAns *= x[i];
        finAns %= mod;
    }
    finAns *= x[maxInd];
    finAns %= mod;
    finAns *= y[maxInd];
    finAns %= mod;
    return finAns;
}

int init(int N, int X[], int Y[]) {
    n = N;
    for (int i = 0; i < n; i++)
    {
        x.push_back(X[i]);
        y.push_back(Y[i]);
    }
    return solveProblem();    
}

int updateX(int pos, int val) {
    x[pos] = val;
    return solveProblem();
}

int updateY(int pos, int val) {
    y[pos] = val;
    return solveProblem();
}

Compilation message

horses.cpp: In function 'int solveProblem()':
horses.cpp:35:12: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   35 |     return finAns;
      |            ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 1 ms 256 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 134 ms 384 KB Output is correct
24 Correct 134 ms 388 KB Output is correct
25 Correct 160 ms 384 KB Output is correct
26 Correct 161 ms 384 KB Output is correct
27 Correct 73 ms 504 KB Output is correct
28 Correct 155 ms 384 KB Output is correct
29 Correct 52 ms 384 KB Output is correct
30 Correct 80 ms 384 KB Output is correct
31 Correct 50 ms 384 KB Output is correct
32 Correct 55 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1547 ms 12252 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 1 ms 288 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 139 ms 504 KB Output is correct
24 Correct 133 ms 384 KB Output is correct
25 Correct 161 ms 384 KB Output is correct
26 Correct 160 ms 384 KB Output is correct
27 Correct 72 ms 384 KB Output is correct
28 Correct 154 ms 388 KB Output is correct
29 Correct 54 ms 384 KB Output is correct
30 Correct 85 ms 384 KB Output is correct
31 Correct 52 ms 384 KB Output is correct
32 Correct 54 ms 384 KB Output is correct
33 Execution timed out 1582 ms 12244 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 360 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 1 ms 356 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 0 ms 256 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 0 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 135 ms 388 KB Output is correct
24 Correct 133 ms 504 KB Output is correct
25 Correct 164 ms 384 KB Output is correct
26 Correct 162 ms 384 KB Output is correct
27 Correct 71 ms 384 KB Output is correct
28 Correct 166 ms 384 KB Output is correct
29 Correct 52 ms 384 KB Output is correct
30 Correct 81 ms 504 KB Output is correct
31 Correct 50 ms 384 KB Output is correct
32 Correct 52 ms 384 KB Output is correct
33 Execution timed out 1589 ms 12252 KB Time limit exceeded
34 Halted 0 ms 0 KB -