# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
139548 | Plurm | Horses (IOI15_horses) | C++11 | 671 ms | 42636 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
multiset<int> mm;
const int MOD = 1e9+7;
long double FT1[500005];
int FT2[500005];
void add(int idx, int amt){
idx++;
while(idx < 500005){
FT1[idx] += log2(amt);
FT2[idx] = (1ll * FT2[idx] * amt) % MOD;
idx += idx & -idx;
}
}
long double sum1(int idx){
idx++;
long double ret = 0;
while(idx > 0){
ret += FT1[idx];
idx -= idx & -idx;
}
return ret;
}
int sum2(int idx){
idx++;
int ret = 1;
while(idx > 0){
ret = (1ll * ret * FT2[idx]) % MOD;
idx -= idx & -idx;
}
return ret;
}
int rx[500005];
int ry[500005];
int answer(){
return *mm.rbegin();
}
int init(int N, int X[], int Y[]) {
for(int i = 0; i < N; i++){
rx[i] = X[i];
ry[i] = Y[i];
}
for(int i = 0; i < 500005; i++) FT2[i] = 1;
for(int i = 0; i < N; i++){
add(i, X[i]);
}
for(int i = 0; i < N; i++){
mm.emplace((int)((1ll * sum2(i) * ry[i]) % MOD));
}
return answer();
}
int updateX(int pos, int val) {
mm.erase(mm.find((int)((1ll * sum2(pos) * ry[pos]) % MOD)));
add(pos, val - rx[pos]);
rx[pos] = val;
mm.emplace((int)((1ll * sum2(pos) * ry[pos]) % MOD));
return answer();
}
int updateY(int pos, int val) {
mm.erase(mm.find((int)((1ll * sum2(pos) * ry[pos]) % MOD)));
ry[pos] = val;
mm.emplace((int)((1ll * sum2(pos) * ry[pos]) % MOD));
return answer();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |