Submission #800798

#TimeUsernameProblemLanguageResultExecution timeMemory
800798LiudasHorses (IOI15_horses)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "horses.h" using namespace std; vector<long long> X, Y; int calc(){ double a = 0, t = 0; int id = 0; for(int i = 0; i < N; i ++){ t += log(X[i]); if(t + log(Y[i]) > a){ a = t + log(Y[i]); id = i; } } long long ans = 1, MOD = 1e9 + 7; ans *= Y[id]; for(int i = 0; i <= id; i ++){ ans = ans * X[i] % MOD; } return ans; } int init(int N, int XX[], int YY[]){ X.resize(N); Y.resize(N); for(int i = 0; i < N; i ++){ X[i] = XX[i]; Y[i] = YY[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 'int calc()':
horses.cpp:8:24: error: 'N' was not declared in this scope
    8 |     for(int i = 0; i < N; i ++){
      |                        ^
horses.cpp:20:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   20 |     return ans;
      |            ^~~