답안 #876046

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876046 2023-11-21T07:13:21 Z Elvin_Fritl 말 (IOI15_horses) C++17
0 / 100
17 ms 19796 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N = 1e5 + 545 , inf = 1e9 + 199 , mod = 1e9 + 7;

     #include "horses.h"
 
ll n , x[N] , y[N];
long double xlog[N] , ylog[N];
 
int calc(){
    long double curr = 1 , mx = 0;
    ll maxi=0;
    for(int i=0;i<n;i++){
        curr += xlog[i];
        if(mx < curr + ylog[i]){
            mx=curr + ylog[i];
            maxi=i;
        }
    }
    
    ll res=1;
    for(int i=0;i<=maxi;i++){
        res *= x[i];
        res %= mod;
    }
    return (res*y[maxi])%mod;
}
 
int init(int N,int X[],int Y[]){
    n=N;
    for(int i=0;i<n;i++){
        x[i]=X[i];
        xlog[i]=log(x[i]);
        y[i]=Y[i];
    }
    return calc();
}
 
int updateX(int pos,int val){
    x[pos]=val;
    xlog[pos] = log(x[pos]);
    return calc();
}
 
int updateY(int pos,int val){
    y[pos]=val;
    ylog[pos] = log(y[pos]);
    return calc();
}

Compilation message

horses.cpp: In function 'int calc()':
horses.cpp:29:25: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   29 |     return (res*y[maxi])%mod;
      |            ~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:32:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   32 | int init(int N,int X[],int Y[]){
      |          ~~~~^
horses.cpp:6:11: note: shadowed declaration is here
    6 | const int N = 1e5 + 545 , inf = 1e9 + 199 , mod = 1e9 + 7;
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Incorrect 1 ms 4556 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4540 KB Output is correct
3 Incorrect 1 ms 4440 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 17 ms 19796 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4544 KB Output is correct
3 Incorrect 1 ms 4444 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Incorrect 1 ms 4444 KB Output isn't correct
4 Halted 0 ms 0 KB -