Submission #1098277

# Submission time Handle Problem Language Result Execution time Memory
1098277 2024-10-09T08:17:08 Z alexander707070 Horses (IOI15_horses) C++14
34 / 100
1500 ms 16176 KB
#include<bits/stdc++.h>
#include "horses.h"

#define MAXN 500007
using namespace std;

const long long mod=1e9+7;

int n;
long long x[MAXN],y[MAXN];

int calc(){
    int best=0;
    long long mult=1;

    for(int i=1;i<=n;i++){
        mult*=x[i];
        if(mult>mod or mult*y[i]>y[best]){
            best=i;
            mult=1;
        }
    }

    mult=1;
    for(int i=1;i<=best;i++){
        mult*=x[i]; mult%=mod;
    }
    mult*=y[best]; mult%=mod;

    return mult;
}

int init(int N, int X[], int Y[]) {
	n=N;
    for(int i=1;i<=n;i++){
        x[i]=X[i-1]; y[i]=Y[i-1];
    }

    return calc();
}

int updateX(int pos, int val) {	
	x[pos+1]=val;
    return calc();
}

int updateY(int pos, int val) {
	y[pos+1]=val;
    return calc();
}

/*int main(){

    init(3,{2,1,3},{3,4,1});
    cout<<updateY(1,2)<<"\n";

    return 0;
}*/

Compilation message

horses.cpp: In function 'int calc()':
horses.cpp:30:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   30 |     return mult;
      |            ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 452 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 8 ms 348 KB Output is correct
24 Correct 7 ms 348 KB Output is correct
25 Correct 8 ms 460 KB Output is correct
26 Correct 8 ms 348 KB Output is correct
27 Correct 7 ms 348 KB Output is correct
28 Correct 8 ms 348 KB Output is correct
29 Correct 6 ms 492 KB Output is correct
30 Correct 7 ms 348 KB Output is correct
31 Correct 4 ms 348 KB Output is correct
32 Correct 5 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1570 ms 12176 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 396 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 8 ms 348 KB Output is correct
24 Correct 8 ms 500 KB Output is correct
25 Correct 8 ms 344 KB Output is correct
26 Correct 8 ms 348 KB Output is correct
27 Correct 7 ms 600 KB Output is correct
28 Correct 8 ms 344 KB Output is correct
29 Correct 6 ms 348 KB Output is correct
30 Correct 7 ms 348 KB Output is correct
31 Correct 4 ms 344 KB Output is correct
32 Correct 5 ms 496 KB Output is correct
33 Execution timed out 1529 ms 16176 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 444 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 448 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 8 ms 360 KB Output is correct
24 Correct 8 ms 348 KB Output is correct
25 Correct 8 ms 484 KB Output is correct
26 Correct 8 ms 348 KB Output is correct
27 Correct 7 ms 348 KB Output is correct
28 Correct 8 ms 500 KB Output is correct
29 Correct 6 ms 348 KB Output is correct
30 Correct 7 ms 500 KB Output is correct
31 Correct 4 ms 348 KB Output is correct
32 Correct 6 ms 348 KB Output is correct
33 Execution timed out 1586 ms 14348 KB Time limit exceeded
34 Halted 0 ms 0 KB -