Submission #438023

#TimeUsernameProblemLanguageResultExecution timeMemory
438023illyakrHorses (IOI15_horses)C++14
34 / 100
1596 ms12060 KiB
#include <bits/stdc++.h> #include "horses.h" using namespace std; #define ll long long const ll mod = 1000000007; const ll mx = 1000000000000000018; ll n; ll x[501010], y[501010]; int gt() { ll cnt = y[n - 1]; ll last = n - 1; for (int i = n - 1; i > 0; i--) { if (x[i] > mx / cnt)cnt = mx; else cnt *= x[i]; if (cnt < y[i - 1]){last = i - 1;cnt = y[i - 1];} if (cnt == mx)break; } ll d = 1; for (int i = 0; i <= last; i++) { d = ((d % mod) * (x[i] % mod)) % mod; } return ((d % mod) * (y[last] % mod)) % mod; } int init(int N, int X[], int Y[]) { n = N; for (ll i = 0; i < n; i++) { x[i] = X[i]; y[i] = Y[i]; } return gt(); } int updateX(int pos, int val) { x[pos] = val; return gt(); } int updateY(int pos, int val) { y[pos] = val; return gt(); }

Compilation message (stderr)

horses.cpp: In function 'int gt()':
horses.cpp:13:20: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   13 |     for (int i = n - 1; i > 0; i--) {
      |                  ~~^~~
horses.cpp:25:42: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   25 |     return ((d % mod) * (y[last] % mod)) % mod;
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
#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...