Submission #597102

#TimeUsernameProblemLanguageResultExecution timeMemory
597102PiejanVDCHorses (IOI15_horses)C++17
34 / 100
1584 ms16192 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; vector<long long>x,y; long long mod = (long long)1000000007; int calc() { int n = (int)x.size(); int last = -1; bool ok = 1; while(ok) { ok = 0; long long c = 1; for(int i = last+1 ; i < n ; i++) { c *= x[i]; c = min(c, (long long)1e9+5); if(c * y[i] > (last == -1 ? 0 : y[last])) { last = i; ok = 1; break; } } } long long C = 1; for(int i = 0 ; i <= last ; i++) C *= x[i], C %= mod; return int((C * y[last])%mod); } int init(int n, int X[], int Y[]) { for(int i = 0 ; i < n ; i++) x.push_back(X[i]), y.push_back(Y[i]); return calc(); } int updateX(int p, int val) { int n = (int)x.size(); x[p] = val; return calc(); } int updateY(int p, int val) { int n = (int)x.size(); y[p] = val; return calc(); }

Compilation message (stderr)

horses.cpp: In function 'int updateX(int, int)':
horses.cpp:42:9: warning: unused variable 'n' [-Wunused-variable]
   42 |     int n = (int)x.size();
      |         ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:48:9: warning: unused variable 'n' [-Wunused-variable]
   48 |     int n = (int)x.size();
      |         ^
#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...