Submission #299238

#TimeUsernameProblemLanguageResultExecution timeMemory
299238ASDF123Horses (IOI15_horses)C++17
17 / 100
1577 ms8208 KiB
#include "horses.h" //#include "grader.cpp" #include <bits/stdc++.h> #define ll long long #define double long double using namespace std; const int N = (int)5e5 + 5; const int MOD = (int)1e9 + 7; const double eps = 1e-9; int x[N], y[N]; int n; int calc() { ll mult = 1; bool subtask1 = true; for (int i = 0; i < n; i++) { mult *= x[i]; if (mult > 1000) { subtask1 = false; break; } } if (subtask1) { ll ans = 0; ll mult = 1; for (int i = 0; i < n; i++) { mult *= x[i]; ans = max(ans, mult * y[i]); } return ans % MOD; } else { int pos = -1; double best = 0; double pref = 0; for (int i = max(0, (n - 1) - 33 + 1); i < n; i++) { pref += log10(x[i]); if (best < pref + log10(y[i])) { best = pref + log10(y[i]); pos = i; } } ll ans = 1; for (int i = 0; i <= pos; i++) { ans *= x[i], ans %= MOD; } ans *= y[pos], ans %= MOD; return ans; } } int init(int NN, int X[], int Y[]) { n = NN; for (int i = 0; i < n; i++) { x[i] = X[i]; y[i] = Y[i]; } return calc(); } int updateX(int pos, int val) { x[pos] = val; return calc(); } int updateY(int pos, int val) { y[pos] = val; return calc(); }

Compilation message (stderr)

horses.cpp: In function 'int calc()':
horses.cpp:27:8: warning: declaration of 'mult' shadows a previous local [-Wshadow]
   27 |     ll mult = 1;
      |        ^~~~
horses.cpp:16:6: note: shadowed declaration is here
   16 |   ll mult = 1;
      |      ^~~~
horses.cpp:32:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   32 |     return ans % MOD;
      |            ~~~~^~~~~
horses.cpp:49:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   49 |     return ans;
      |            ^~~
#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...