Submission #299221

#TimeUsernameProblemLanguageResultExecution timeMemory
299221ASDF123Horses (IOI15_horses)C++17
0 / 100
1576 ms8192 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; double get(double x) { double r = 10; double l = 0; while(r-l>eps){ double m = (l+r)/2; if ( pow(10, m) > x) r=m; else l=m; } return l; } int calc() { int pos = -1; double best = 0; double pref = 0; for (int i = 0; i < n; i++) { pref += (double)get(x[i]*1.0); if (pref + (double)get(y[i]*1.0) - best > eps) { best = pref + get(y[i]*1.0); pos = i; } } long long 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 'long double get(long double)':
horses.cpp:15:20: warning: declaration of 'x' shadows a global declaration [-Wshadow]
   15 | double get(double x) {
      |                    ^
horses.cpp:12:5: note: shadowed declaration is here
   12 | int x[N], y[N];
      |     ^
horses.cpp: In function 'int calc()':
horses.cpp:44:10: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   44 |   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...