Submission #387375

#TimeUsernameProblemLanguageResultExecution timeMemory
387375alishahali1382Horses (IOI15_horses)C++14
54 / 100
1578 ms18412 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define debug(x) {cerr<<#x<<"="<<x<<"\n";} #define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";} #define debug2(x, y) {cerr<<#x<<", "<<#y<<" = "<<x<<", "<<y<<"\n";} #define pb push_back #define all(x) x.begin(), x.end() const int mod=1000000007; const int MAXN=500010, LOG=20; int n, m, k; ll X[MAXN], Y[MAXN], zarbx=1; ll powmod(ll a, ll b){ ll res=1; for (; b; b>>=1, a=a*a%mod) if (b&1) res=res*a%mod; return res; } int Solve(){ ll ansx=1, ansy=0, xx=1; for (int i=n-1; ~i; i--){ if (xx*ansy<ansx*Y[i]){ ansx=xx; ansy=Y[i]; } xx*=X[i]; if (xx>=1000000000) break ; } return zarbx*powmod(ansx, mod-2)%mod*ansy%mod; } 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]; zarbx=zarbx*X[i]%mod; } return Solve(); } int updateX(int pos, int val) { zarbx=zarbx*powmod(X[pos], mod-2)%mod; X[pos]=val; zarbx=zarbx*X[pos]%mod; return Solve(); } int updateY(int pos, int val) { Y[pos]=val; return Solve(); }

Compilation message (stderr)

horses.cpp: In function 'int Solve()':
horses.cpp:35:43: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   35 |  return zarbx*powmod(ansx, mod-2)%mod*ansy%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...