Submission #1049827

#TimeUsernameProblemLanguageResultExecution timeMemory
1049827TAhmed33Horses (IOI15_horses)C++98
34 / 100
1593 ms12116 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; int add (int a, int b) { a += b; if (a >= MOD) a -= MOD; return a; } int sub (int a, int b) { a -= b; if (a < 0) a += MOD; return a; } int mul (int a, int b) { return (a * 1ll * b) % MOD; } const int MAXN = 5e5 + 25; int x[MAXN], y[MAXN], n; int ans () { long double s = log2(x[0]); long double cur = s + log2(y[0]); int pos = 0; for (int i = 1; i < n; i++) { s += log2(x[i]); long double t = s + log2(y[i]); if (t > cur + 1e-9) { cur = t; pos = i; } } int ret = 1; for (int i = 0; i <= pos; i++) { ret = mul(ret, x[i]); } ret = mul(ret, y[pos]); return ret; } 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 ans(); } int updateX (int pos, int val) { x[pos] = val; return ans(); } int updateY (int pos, int val) { y[pos] = val; return ans(); }

Compilation message (stderr)

horses.cpp: In function 'int mul(int, int)':
horses.cpp:14:23: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   14 |  return (a * 1ll * b) % 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...