답안 #876048

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876048 2023-11-21T07:17:56 Z Elvin_Fritl 말 (IOI15_horses) C++17
0 / 100
16 ms 18012 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(){
    ll curr = 1 , mx = 0 ,  ind=0;
    for(int i=0;i<n;i++){
        curr += xlog[i];
        if(mx < curr + ylog[i]){
            mx = curr + ylog[i];
            ind = i;
        }
    }
    
    ll res=1;
    for(int i=0;i<=ind;i++){
        res *= x[i];
        res %= mod;
    }
    return (res*y[ind])%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];
        ylog[i] = log(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:16:14: warning: conversion from 'long double' to 'll' {aka 'long long int'} may change value [-Wfloat-conversion]
   16 |         curr += xlog[i];
      |         ~~~~~^~~~~~~~~~
horses.cpp:18:23: warning: conversion from 'long double' to 'll' {aka 'long long int'} may change value [-Wfloat-conversion]
   18 |             mx = curr + ylog[i];
      |                  ~~~~~^~~~~~~~~
horses.cpp:28:24: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   28 |     return (res*y[ind])%mod;
      |            ~~~~~~~~~~~~^~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:31:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   31 | 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 4444 KB Output is correct
2 Incorrect 1 ms 4444 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Incorrect 1 ms 4444 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 16 ms 18012 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Incorrect 1 ms 4444 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Incorrect 1 ms 4444 KB Output isn't correct
3 Halted 0 ms 0 KB -