답안 #320372

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320372 2020-11-08T11:54:42 Z nikatamliani 말 (IOI15_horses) C++14
0 / 100
1500 ms 31716 KB
#include <bits/stdc++.h>
#include "horses.h"
#define ll long long
using namespace std;
const ll MOD = 1e9 + 7, MAXN = 5e5 + 10;
set < int > s;
int X[MAXN], Y[MAXN], N;
int solve() {
    vector < int > v;
    for(int x : s) {
        v.push_back(-x);
        if(v.size() == 30) break;
    }
    reverse(v.begin(), v.end());
    v.push_back(N);
    ll product = 1, answer = 0;
    for(int i = 0; i < (int) v.size() - 1; ++i) {
        product *= X[v[i]];
        ll maximum = 0; 
        for(int j = v[i]; j < v[i + 1]; ++j) {
            maximum = max(maximum, (ll)Y[j]);
        }
        answer = max(answer, maximum * product);
    }
    if(!v.empty()) {
        for(int i = 0; i < v[0]; ++i) {
            answer *= X[i];
            answer %= MOD;
        }
    }
    return answer;
}
int updateX(int pos, int val) {
    if(X[pos] > 1) s.erase(s.find(-pos));
    X[pos] = val;
    if(X[pos] > 1) s.insert(-pos);
    return solve();
}
int updateY(int pos, int val) {
    Y[pos] = val;
    return solve();
}
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];
        if(X[i] > 1) s.insert(-i);
    }
    return solve();
}
// int main() {
//     int X[] = {2, 1, 3};
//     int Y[] = {3, 4, 1};
//     cout << init(3, X, Y) << '\n';
//     cout << updateY(1, 2) << '\n';
// }

Compilation message

horses.cpp: In function 'int solve()':
horses.cpp:31:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   31 |     return answer;
      |            ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 0 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 0 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1559 ms 31716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 0 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -