Submission #833745

#TimeUsernameProblemLanguageResultExecution timeMemory
833745TB_Horses (IOI15_horses)C++17
0 / 100
1577 ms14376 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define INF (ll)1e9+7 #define fo(i, x) for(ll i = 0; i<x;i++) #define pb push_back typedef vector<ll> vl; vl x, y; ll eval(){ ll ans = 0, current = 1; double bestLog = 0, currentLog = 0; int n = x.size(); fo(i, n){ current = (current*x[i])%(INF); currentLog += log10l(x[i]); if(currentLog+log10l(y[i]) > bestLog){ bestLog = currentLog+log10l(y[i]); ans = (current*y[i])%(INF); } } return ans; } int init(int N, int X[], int Y[]) { fo(i, N){ x.pb(X[i]); y.pb(Y[i]); } return eval(); } int updateX(int pos, int val) { x[pos] = val; return eval(); } int updateY(int pos, int val) { y[pos] = val; return eval(); } // 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"); // _outputFile = fopen("horses.out", "w"); // 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(); // } // fprintf(_outputFile,"%d\n",init(N,X,Y)); // 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) { // fprintf(_outputFile,"%d\n",updateX(pos,val)); // } else if (type == 2) { // fprintf(_outputFile,"%d\n",updateY(pos,val)); // } // } // return 0; // }

Compilation message (stderr)

horses.cpp: In function 'long long int eval()':
horses.cpp:17:16: warning: conversion from 'std::vector<long long int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   17 |  int n = x.size();
      |          ~~~~~~^~
horses.cpp:20:28: warning: conversion from 'long double' to 'double' may change value [-Wfloat-conversion]
   20 |   currentLog += log10l(x[i]);
      |                            ^
horses.cpp:22:24: warning: conversion from 'long double' to 'double' may change value [-Wfloat-conversion]
   22 |    bestLog = currentLog+log10l(y[i]);
      |              ~~~~~~~~~~^~~~~~~~~~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:34:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   34 |  return eval();
      |         ~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:39:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   39 |  return eval();
      |         ~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:44:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   44 |  return eval();
      |         ~~~~^~
#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...