Submission #802113

#TimeUsernameProblemLanguageResultExecution timeMemory
802113jlallas384Horses (IOI15_horses)C++17
34 / 100
1568 ms8144 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; using ll = long long; const int mod = 1e9 + 7; vector<int> x, y; int n; int solve(){ ll hv = 1; for(int i = 0; i < n; i++){ hv = hv * x[i] % mod; ll pre = 1; ll bst = 0; for(int j = i + 1; j < n; j++){ if(bst == -1) break; pre *= x[j]; if(pre > 1e9) bst = -1; else bst = max(bst, pre * y[j]); } if(bst != -1 && y[i] > bst){ return hv * y[i] % mod; } } } int init(int N, int X[], int Y[]) { n = N; x.resize(n), y.resize(n); for(int i = 0; i < n; i++){ x[i] = X[i]; y[i] = Y[i]; } return solve(); } int updateX(int pos, int val) { x[pos] = val; return solve(); } int updateY(int pos, int val) { y[pos] = val; return solve(); }

Compilation message (stderr)

horses.cpp: In function 'int solve()':
horses.cpp:19:7: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   19 |    if(pre > 1e9) bst = -1;
      |       ^~~
horses.cpp:23:21: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   23 |    return hv * y[i] % mod;
      |           ~~~~~~~~~~^~~~~
horses.cpp:26:1: warning: control reaches end of non-void function [-Wreturn-type]
   26 | }
      | ^
#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...