Submission #834304

# Submission time Handle Problem Language Result Execution time Memory
834304 2023-08-22T12:50:25 Z Ellinor Horses (IOI15_horses) C++14
0 / 100
1500 ms 14208 KB
//#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <cstdlib>
#include <set>
#include <iomanip>
#include <limits>
#include <map>
#include <assert.h>
#include <algorithm>
#include <list>
#include <iterator>
#include <fstream>
#include <random>
#include <unordered_map>
#include <array>
using namespace std;

#define rep(i,a,b) for (int i = (a); i < b; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;

ll MOD = 1e9 + 7; // !?

// fast

//

#include "horses.h" // !

int n;
vector<ll> x, y;

int go()
{
    ll ch = 1, tmp = 1e9;
    int sind = -1;
    for (int i = n - 1; i >= 0; i--)
    {
        ch *= x[i];
        if (ch >= tmp) {
            sind = i; // :/
            break;
        }
    }

    ll ans = 0, tmp1;
    ll horses = 1;
    rep(i,sind,n) { // start on sind -1" = 1
        horses *= x[i];
        if (i == n-1) {
            double tmp2 = ans / horses;
            if (y[i] > tmp2) {
                horses %= MOD;
                ans = horses * y[i];
            }
            else break;
        }
        tmp1 = horses * y[i];
        ans = max(ans, tmp1);
    }

    // sind -> 1
    // sind -> ?
    tmp = 1;
    rep(i,0,sind) {
        tmp *= x[i];
        tmp %= MOD;
    }

    ans = ans % MOD;
    ans *= tmp;
    ans = ans % MOD;
	return ans;
}

int init(int N, int X[], int Y[]) 
{
    n = N;
    x.assign(N, 0);
    y.assign(N, 0);
    rep(i,0,N) {
        x[i] = X[i];
        y[i] = Y[i];
    }

    return go();
}

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

    return go();
}

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

    return go();
}

// 17p, M = 0

Compilation message

horses.cpp: In function 'int go()':
horses.cpp:57:31: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   57 |             double tmp2 = ans / horses;
      |                           ~~~~^~~~~~~~
horses.cpp:58:24: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'double' may change value [-Wconversion]
   58 |             if (y[i] > tmp2) {
      |                        ^~~~
horses.cpp:79:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   79 |  return ans;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1506 ms 14208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -