답안 #998707

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
998707 2024-06-14T14:31:04 Z inesfi 말 (IOI15_horses) C++14
0 / 100
12 ms 10588 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];
    }
    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;
                if (prix[iannee]>prix[iannee-1]){
                    encours.pop_back();
                    encours.push_back(iannee);
                    meilleur=prix[iannee];
                }
                else {
                    meilleur=prix[iannee-1];
                }
            }
            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()-31,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%=MODULO;
	//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:21:31: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   21 |     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]);
      |                      ~~~~~~~~~^
# 결과 실행 시간 메모리 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 10588 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 344 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -