Submission #291403

#TimeUsernameProblemLanguageResultExecution timeMemory
291403MarcoMeijerHorses (IOI15_horses)C++14
34 / 100
1588 ms16088 KiB
#include <bits/stdc++.h>

using namespace std;

#include "horses.h"

//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
#define sz size()

const int MX = 5e5+10;
const int MOD = 1e9+7;
ll n, x[MX], y[MX];

int getAns() {
    ll bst = 1;
    int i=n-1;
    while(i >= 0) {
        bst = max(bst, y[i]);
        bst *= x[i];
        i--;
        if(bst >= INF) {
            break;
        }
    }
    bst %= MOD;
    while(i >= 0) {
        bst = (bst*x[i])%MOD;
        i--;
    }
    return bst;
}

int init(int N, int X[], int Y[]) {
    n=N;
    RE(i,n) x[i]=X[i];
    RE(i,n) y[i]=Y[i];
	return getAns();
}

int updateX(int pos, int val) {	
    x[pos] = val;
	return getAns();
}

int updateY(int pos, int val) {
    y[pos] = val;
	return getAns();
}

Compilation message (stderr)

horses.cpp: In function 'int getAns()':
horses.cpp:34:12: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   34 |     int i=n-1;
      |           ~^~
horses.cpp:39:12: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   39 |         if(bst >= INF) {
      |            ^~~
horses.cpp:48:12: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   48 |     return bst;
      |            ^~~
#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...