Submission #597100

#TimeUsernameProblemLanguageResultExecution timeMemory
597100ApiramHorses (IOI15_horses)C++14
17 / 100
1563 ms9292 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int init(int N, int X[], int Y[]) { int ans = 0; vector<long long>numhorse(N + 1,0); numhorse[0] = 1; for (int i = 0;i<N;++i){ numhorse[i + 1] = (numhorse[i] * X[i])%mod; } //(numhorse[i + 1] * Y[i] > y[j] * number of horse[j + 1] long long maxxy = Y[N - 1],index = N - 1; ans = (numhorse[N] * Y[N - 1])%mod; for (int i = N - 1;i>=1;--i){ long long temp = 1; bool ok = false; for (int j = i;j <=index;++j){ temp = (temp * X[j]); if (temp > 1e9)ok = true; } //cout<<temp<<" "<<Y[i - 1] / Y[index]<<" "<<i<<" "<<maxxy<<" "<<index<<'\n'; if (Y[i - 1] > maxxy && (ok || temp <= Y[i - 1] / Y[index])){ maxxy = Y[i - 1]; index = i - 1; ans = (numhorse[i] * Y[i - 1])%mod; } } return ans; } int updateX(int pos, int val) { return 0; } int updateY(int pos, int val) { return 0; }

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:14:32: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   14 |  ans = (numhorse[N] * Y[N - 1])%mod;
      |        ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp:20:8: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   20 |    if (temp > 1e9)ok = true;
      |        ^~~~
horses.cpp:26:34: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   26 |    ans = (numhorse[i] * Y[i - 1])%mod;
      |          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:32:17: warning: unused parameter 'pos' [-Wunused-parameter]
   32 | int updateX(int pos, int val) {
      |             ~~~~^~~
horses.cpp:32:26: warning: unused parameter 'val' [-Wunused-parameter]
   32 | int updateX(int pos, int val) {
      |                      ~~~~^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:36:17: warning: unused parameter 'pos' [-Wunused-parameter]
   36 | int updateY(int pos, int val) {
      |             ~~~~^~~
horses.cpp:36:26: warning: unused parameter 'val' [-Wunused-parameter]
   36 | int updateY(int pos, int val) {
      |                      ~~~~^~~
#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...