Submission #778205

# Submission time Handle Problem Language Result Execution time Memory
778205 2023-07-10T07:26:18 Z danikoynov Horses (IOI15_horses) C++14
34 / 100
1500 ms 15968 KB
#include "horses.h"
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 5e5 + 10;
const ll mod = 1e9 + 7;
ll x[maxn], y[maxn], n;

ll action()
{
    ll up = y[n - 1], dw = 1, pos = n - 1;
    ll div = 1;
    for (int i = n - 2; i >= 0; i --)
    {
        div = div * x[i + 1];
        if (div > 1e9)
            break;
            ///cout << i << " : " << y[i] << " " << div << endl;
        /// y[i] / div >? up / dw
        if (y[i] * dw >= up * div)
        {

            ///cout << " " << up << " : " << dw << endl;
            up = y[i];
            dw = div;
            pos = i;
        }
    }

    ///cout << pos << endl;
    ll ans = 1;
    for (int i = 0; i <= pos; i ++)
        ans = (ans * x[i]) % mod;
    ans = (ans * y[pos]) % mod;
    return ans;
}
int init(int N, int X[], int Y[])
{
    n = N;
    for (int i = 0; i < n; i ++)
    {
        x[i] = X[i];
        y[i] = Y[i];
    }
    return action();
}

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

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

Compilation message

horses.cpp: In function 'll action()':
horses.cpp:15:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   15 |     for (int i = n - 2; i >= 0; i --)
      |                  ~~^~~
horses.cpp:18:13: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   18 |         if (div > 1e9)
      |             ^~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:47:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   47 |     return action();
      |            ~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:53:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   53 |     return action();
      |            ~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:59:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   59 |     return action();
      |            ~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 5 ms 364 KB Output is correct
24 Correct 6 ms 324 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 344 KB Output is correct
27 Correct 5 ms 340 KB Output is correct
28 Correct 5 ms 364 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 5 ms 360 KB Output is correct
31 Correct 5 ms 328 KB Output is correct
32 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1561 ms 14164 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 5 ms 340 KB Output is correct
24 Correct 5 ms 320 KB Output is correct
25 Correct 5 ms 340 KB Output is correct
26 Correct 5 ms 344 KB Output is correct
27 Correct 5 ms 340 KB Output is correct
28 Correct 5 ms 340 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 5 ms 364 KB Output is correct
31 Correct 4 ms 320 KB Output is correct
32 Correct 4 ms 340 KB Output is correct
33 Execution timed out 1583 ms 15968 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 316 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 5 ms 328 KB Output is correct
24 Correct 5 ms 340 KB Output is correct
25 Correct 5 ms 348 KB Output is correct
26 Correct 5 ms 340 KB Output is correct
27 Correct 5 ms 340 KB Output is correct
28 Correct 5 ms 360 KB Output is correct
29 Correct 6 ms 320 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 5 ms 340 KB Output is correct
32 Correct 4 ms 340 KB Output is correct
33 Execution timed out 1581 ms 14204 KB Time limit exceeded
34 Halted 0 ms 0 KB -