Submission #998727

# Submission time Handle Problem Language Result Execution time Memory
998727 2024-06-14T15:20:18 Z inesfi Horses (IOI15_horses) C++17
34 / 100
19 ms 12372 KB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;

#define ll long long

const ll TAILLEMAXI=1002,MODULO=1000*1000*1000+7;
ll nbannees,deb,avant,meilleur,atester,fin,produit,rep,zero;
ll nbmulti[TAILLEMAXI],prix[TAILLEMAXI];
vector<ll> encours;

int updateX(int pos, int val);

int init (int N, int X[], int Y[]){
	//cout<<42<<endl;
    nbannees=N;
    for (int iannee=0;iannee<N;iannee++){
        nbmulti[iannee]=X[iannee];
        prix[iannee]=Y[iannee];
    }
	nbannees++;
	nbmulti[nbannees-1]=1;
	prix[nbannees-1]=1;
    return updateX(0,nbmulti[0]);
}

int updateX(int pos, int val){
    nbmulti[pos]=val;
    deb=nbmulti[0];
    avant=0;
    meilleur=0;
    encours.clear();
    encours.push_back(0);
    for (int iannee=1;iannee<nbannees;iannee++){
        if (nbmulti[iannee]==1){
            if (avant==0){
                avant=1;
                meilleur=prix[iannee];
				encours.push_back(iannee);
            }
            else {
                if (prix[iannee]>meilleur){
                    encours.pop_back();
                    encours.push_back(iannee);
                    meilleur=prix[iannee];
                }
            }
        }
        else {
            avant=0;
            encours.push_back(iannee);
        }
    }
	zero=0;
    atester=max((ll)encours.size()-62,zero);
    fin=atester+1;
    produit=1;
    while (fin<(int)encours.size()){
        if (prix[encours[atester]]>=prix[encours[fin]]*produit 
		and prix[encours[atester]]>=prix[encours[fin]]*produit*nbmulti[encours[fin]]){
            produit*=nbmulti[encours[fin]];
        }
        else {
            atester=fin;
            produit=1;
        }
		fin++;
    }
    rep=1;
    for (int i=0;i<=encours[atester];i++){
        rep*=nbmulti[i];
        rep=rep%MODULO;
    }
    rep*=prix[encours[atester]];
    rep=rep%MODULO;
	//for (int i=0;i<(ll)encours.size();i++){
		//cout<<encours[i]<<endl;
	//}
	//cout<<rep<<endl;
    return rep;
}

int updateY(int pos, int val){
    prix[pos]=val;
    return updateX(0,nbmulti[0]);
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:24:31: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   24 |     return updateX(0,nbmulti[0]);
      |                      ~~~~~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:80:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   80 |     return rep;
      |            ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:85:31: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   85 |     return updateX(0,nbmulti[0]);
      |                      ~~~~~~~~~^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 508 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 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 600 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 0 ms 388 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 440 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 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 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 1 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
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 6 ms 348 KB Output is correct
24 Correct 6 ms 348 KB Output is correct
25 Correct 7 ms 348 KB Output is correct
26 Correct 6 ms 348 KB Output is correct
27 Correct 6 ms 348 KB Output is correct
28 Correct 7 ms 348 KB Output is correct
29 Correct 4 ms 348 KB Output is correct
30 Correct 5 ms 496 KB Output is correct
31 Correct 5 ms 344 KB Output is correct
32 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 12 ms 9556 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 440 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 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 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
21 Correct 0 ms 440 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 7 ms 500 KB Output is correct
24 Correct 6 ms 348 KB Output is correct
25 Correct 6 ms 348 KB Output is correct
26 Correct 7 ms 604 KB Output is correct
27 Correct 6 ms 348 KB Output is correct
28 Correct 7 ms 348 KB Output is correct
29 Correct 4 ms 348 KB Output is correct
30 Correct 5 ms 492 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 4 ms 348 KB Output is correct
33 Runtime error 19 ms 12372 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 436 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 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 1 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
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 6 ms 348 KB Output is correct
24 Correct 7 ms 348 KB Output is correct
25 Correct 6 ms 348 KB Output is correct
26 Correct 6 ms 468 KB Output is correct
27 Correct 6 ms 348 KB Output is correct
28 Correct 6 ms 344 KB Output is correct
29 Correct 4 ms 348 KB Output is correct
30 Correct 5 ms 492 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 4 ms 404 KB Output is correct
33 Runtime error 11 ms 10588 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -