제출 #800803

#제출 시각아이디문제언어결과실행 시간메모리
800803Liudas말 (IOI15_horses)C++17
34 / 100
176 ms25620 KiB
#include <bits/stdc++.h>
#include "horses.h"
using namespace std;
vector<long long> X, Y;
long long N, Z = 0;
long long MOD = 1e9 + 7;
int calc(){
    double a = 0, t = 0;
    int id = 0;
    for(int i = 0; i < N; i ++){
        t += log(X[i]);
        if(t + log(Y[i]) > a){
            a = t + log(Y[i]);
            id = i;
        }
    }
    long long ans = 1;
    ans *= Y[id];
    for(int i = 0; i <= id; i ++){
        ans = ans * X[i] % MOD;
    }
    return ans;
}
int calc1(){
    double a = 0, t = 0;
    int id = 0;
    for(int i = N - 40; i < N; i ++){
        t += log(X[i]);
        if(t + log(Y[i]) > a){
            a = t + log(Y[i]);
            id = i;
        }
    }
    long long ans = 1;
    if(!Z){
        Z = 1;
        for(int i = 0; i < N - 40; i ++){
            Z = Z * X[i] % MOD;
        }
    }
    ans = ans * Y[id] * Z % MOD;
    for(int i = N - 40; i <= id; i ++){
        ans = ans * X[i] % MOD;
    }
    return ans;
}
int init(int NN, int XX[], int YY[]){
    N = NN;
    X.resize(N);
    Y.resize(N);
    for(int i = 0; i < N; i ++){
        X[i] = XX[i];
        Y[i] = YY[i];
    }
    return calc();
}
int updateX(int pos, int val){
    X[pos] = val;
    return (X.size() > 1000 ? calc1() : calc());
}
int updateY(int pos, int val){
    Y[pos] = val;
    return (X.size() > 1000 ? calc1() : calc());
}

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In function 'int calc()':
horses.cpp:22:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   22 |     return ans;
      |            ^~~
horses.cpp: In function 'int calc1()':
horses.cpp:27:19: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   27 |     for(int i = N - 40; i < N; i ++){
      |                 ~~^~~~
horses.cpp:42:19: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   42 |     for(int i = N - 40; i <= id; i ++){
      |                 ~~^~~~
horses.cpp:45:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   45 |     return ans;
      |            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...