Submission #387659

#TimeUsernameProblemLanguageResultExecution timeMemory
387659Pichon5Horses (IOI15_horses)C++17
17 / 100
1585 ms15948 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1e9 + 7; const int maxn = 5e5 + 10; int n; ll x[maxn], y[maxn], pref[maxn]; int solve() { ll prod = 1, last = 0, mx = 0; for(int i = 0; i < n; i++) { prod *= x[i]; if((long double)y[i] * prod > last) { mx = pref[i] * y[i] % mod; prod = 1; last = y[i]; } } return mx; } 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]; pref[0] = x[0]; for(int i = 1; i < N; i++) { pref[i] = pref[i - 1] * x[i] % mod; } 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:11: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   19 |  } return mx;
      |           ^~
#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...