Submission #299280

#TimeUsernameProblemLanguageResultExecution timeMemory
299280ASDF123Horses (IOI15_horses)C++17
0 / 100
176 ms16632 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; ll tree[N * 4]; void upd(int pos, int val, int v = 1, int tl = 1, int tr = N) { if (tl == tr) { tree[v] = val; return; } int mid = (tl + tr) >> 1; if (pos <= mid) { upd(pos, val, v + v, tl, mid); } else { upd(pos, val, v + v + 1, mid + 1, tr); } tree[v] = (tree[v + v] * tree[v + v + 1]) % MOD; } ll get(int l, int r, int v = 1, int tl = 1, int tr = N) { if (l <= tl && tr <= r) { return tree[v]; } if (l > tr || tl > r) { return 1ll; } int mid = (tl + tr) >> 1; return (get(l, r, v + v, tl, mid) * get(l, r, v + v + 1, mid + 1, tr)) % MOD; } int calc() { bool subtask1 = false; 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 = max(0, (n - 1) - 31 + 1); while (1) { int next = -1; ll mult = 1; for (int i = pos + 1; pos < n; pos++) { mult *= x[i]; if (mult > y[pos]) { next = i; break; } if (mult * y[i] > y[pos]) { next = i; break; } } if (next == -1) { break; } else { pos = next; } } ll ans = (get(0, pos) * y[pos]) % 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]; upd(i, x[i]); } return calc(); } int updateX(int pos, int val) { x[pos] = val; upd(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:51:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   51 |     return ans % MOD;
      |            ~~~~^~~~~
horses.cpp:75:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   75 |     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...