Submission #597102

# Submission time Handle Problem Language Result Execution time Memory
597102 2022-07-15T13:50:46 Z PiejanVDC Horses (IOI15_horses) C++17
34 / 100
1500 ms 16192 KB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;

vector<long long>x,y;

long long mod = (long long)1000000007;

int calc() {
    int n = (int)x.size();

    int last = -1;

    bool ok = 1;
    while(ok) {
        ok = 0;
        long long c = 1;
        for(int i = last+1 ; i < n ; i++) {
            c *= x[i];
            c = min(c, (long long)1e9+5);
            if(c * y[i] > (last == -1 ? 0 : y[last])) {
                last = i;
                ok = 1;
                break;
            }
        }
    }

    long long C = 1;
    for(int i = 0 ; i <= last ; i++)
        C *= x[i], C %= mod;
    return int((C * y[last])%mod);
}

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

int updateX(int p, int val) {
    int n = (int)x.size();
    x[p] = val;
    return calc();
}

int updateY(int p, int val) {
    int n = (int)x.size();
    y[p] = val;
    return calc();
}

Compilation message

horses.cpp: In function 'int updateX(int, int)':
horses.cpp:42:9: warning: unused variable 'n' [-Wunused-variable]
   42 |     int n = (int)x.size();
      |         ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:48:9: warning: unused variable 'n' [-Wunused-variable]
   48 |     int n = (int)x.size();
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 0 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 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 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 0 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 0 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 1 ms 212 KB Output is correct
19 Correct 0 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 8 ms 348 KB Output is correct
24 Correct 8 ms 308 KB Output is correct
25 Correct 12 ms 360 KB Output is correct
26 Correct 12 ms 340 KB Output is correct
27 Correct 7 ms 436 KB Output is correct
28 Correct 9 ms 340 KB Output is correct
29 Correct 6 ms 212 KB Output is correct
30 Correct 10 ms 340 KB Output is correct
31 Correct 4 ms 340 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1584 ms 12272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 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 0 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 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 0 ms 212 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 8 ms 360 KB Output is correct
24 Correct 9 ms 308 KB Output is correct
25 Correct 12 ms 468 KB Output is correct
26 Correct 12 ms 340 KB Output is correct
27 Correct 7 ms 312 KB Output is correct
28 Correct 8 ms 340 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 9 ms 312 KB Output is correct
31 Correct 4 ms 340 KB Output is correct
32 Correct 6 ms 340 KB Output is correct
33 Execution timed out 1554 ms 16192 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 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 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 0 ms 212 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 9 ms 348 KB Output is correct
24 Correct 8 ms 340 KB Output is correct
25 Correct 13 ms 364 KB Output is correct
26 Correct 13 ms 332 KB Output is correct
27 Correct 8 ms 352 KB Output is correct
28 Correct 8 ms 340 KB Output is correct
29 Correct 6 ms 212 KB Output is correct
30 Correct 9 ms 348 KB Output is correct
31 Correct 4 ms 312 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Execution timed out 1576 ms 14428 KB Time limit exceeded
34 Halted 0 ms 0 KB -