제출 #778205

#제출 시각아이디문제언어결과실행 시간메모리
778205danikoynov말 (IOI15_horses)C++14
34 / 100
1583 ms15968 KiB
#include "horses.h"
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 5e5 + 10;
const ll mod = 1e9 + 7;
ll x[maxn], y[maxn], n;

ll action()
{
    ll up = y[n - 1], dw = 1, pos = n - 1;
    ll div = 1;
    for (int i = n - 2; i >= 0; i --)
    {
        div = div * x[i + 1];
        if (div > 1e9)
            break;
            ///cout << i << " : " << y[i] << " " << div << endl;
        /// y[i] / div >? up / dw
        if (y[i] * dw >= up * div)
        {

            ///cout << " " << up << " : " << dw << endl;
            up = y[i];
            dw = div;
            pos = i;
        }
    }

    ///cout << pos << endl;
    ll ans = 1;
    for (int i = 0; i <= pos; i ++)
        ans = (ans * x[i]) % mod;
    ans = (ans * y[pos]) % mod;
    return ans;
}
int init(int N, int X[], int Y[])
{
    n = N;
    for (int i = 0; i < n; i ++)
    {
        x[i] = X[i];
        y[i] = Y[i];
    }
    return action();
}

int updateX(int pos, int val)
{
    x[pos] = val;
    return action();
}

int updateY(int pos, int val)
{
    y[pos] = val;
    return action();
}

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

horses.cpp: In function 'll action()':
horses.cpp:15:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   15 |     for (int i = n - 2; i >= 0; i --)
      |                  ~~^~~
horses.cpp:18:13: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   18 |         if (div > 1e9)
      |             ^~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:47:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   47 |     return action();
      |            ~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:53:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   53 |     return action();
      |            ~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:59:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   59 |     return action();
      |            ~~~~~~^~
#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...