Submission #989022

#TimeUsernameProblemLanguageResultExecution timeMemory
989022crafticatHorses (IOI15_horses)C++17
17 / 100
1563 ms8284 KiB
#include <bits/stdc++.h> using namespace std; constexpr int MOD = 1e9 + 7; using ll = long long; constexpr ll mex = 1e18 + 7; vector<int> x, y; int n; int solve() { pair<ll,ll> mult = {1,0}; pair<ll,ll> ans = {0,0}; for (int i = 0; i < n; ++i) { mult.first *= x[i]; if (mult.first >= MOD) { mult.second += mult.first / MOD; mult.first %= MOD; } pair<ll,ll> m2 = {mult.first * y[i],mult.second}; if (m2.first >= MOD) { m2.second += m2.first / MOD; m2.first %= MOD; } if (m2.second > ans.second || (m2.second == ans.second && m2.first > ans.first)) ans = m2; } return ans.first % MOD; } int init(int N, int X[], int Y[]) { n = N; x.resize(N); y.resize(N); for (int i = 0; i < N; ++i) { x[i] = X[i]; y[i] = Y[i]; } return solve(); } int updateX(int pos, int val) { x[pos] = val; return solve(); } int updateY(int pos, int val) { y[pos] = val; return solve(); } #if DEBUG static char _buffer[1024]; static int _currentChar = 0; static int _charsNumber = 0; static FILE *_inputFile, *_outputFile; static inline int _read() { if (_charsNumber < 0) { exit(1); } if (!_charsNumber || _currentChar == _charsNumber) { _charsNumber = (int)fread(_buffer, sizeof(_buffer[0]), sizeof(_buffer), _inputFile); _currentChar = 0; } if (_charsNumber <= 0) { return -1; } return _buffer[_currentChar++]; } static inline int _readInt() { int c, x, s; c = _read(); while (c <= 32) c = _read(); x = 0; s = 1; if (c == '-') { s = -1; c = _read(); } while (c > 32) { x *= 10; x += c - '0'; c = _read(); } if (s < 0) x = -x; return x; } int main() { _inputFile = fopen("horses.in", "rb"); int N; N = _readInt(); int *X = (int*)malloc(sizeof(int)*(unsigned int)N); int *Y = (int*)malloc(sizeof(int)*(unsigned int)N); for (int i = 0; i < N; i++) { X[i] = _readInt(); } for (int i = 0; i < N; i++) { Y[i] = _readInt(); } cout << init(N,X,Y) << endl; int M; M = _readInt(); for (int i = 0; i < M; i++) { int type; type = _readInt(); int pos; pos = _readInt(); int val; val = _readInt(); if (type == 1) { cout << updateX(pos,val) << endl; } else if (type == 2) { cout << updateY(pos,val) << endl; } } return 0; } #endif

Compilation message (stderr)

horses.cpp: In function 'int solve()':
horses.cpp:29:22: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   29 |     return ans.first % MOD;
      |            ~~~~~~~~~~^~~~~
#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...