Submission #231817

#TimeUsernameProblemLanguageResultExecution timeMemory
231817MasterdanHorses (IOI15_horses)C++14
34 / 100
29 ms12368 KiB
#include "horses.h" #include <bits/stdc++.h> #define MIN -1 #define MAX 1e9+7 #define all(a) a.begin (), a.end () #define pb push_back #define mp make_pair #define F first #define S second #define mem(a, c) memset(a, c, sizeof(a)) using namespace std; typedef vector <int> vi; typedef long long int ll; typedef pair <int, int> ii; typedef vector <ll> vll; int n; ll lol=MAX; ll vx[1010], vy[1010]; ll solve(){ ll ans=(vx[0]*vy[0])%lol; ll prod=ll(1); ll pref=vx[0]; int flag=0; for(int i=1;i<n;i++){ prod*=vx[i]; ll aux=prod*vy[i]; pref*=vx[i]; pref%=lol; if(aux>=vy[flag]) { ans=(pref*vy[i])%lol; prod=ll(1); flag=i; } } return ans%lol; } int init(int N, int x[], int y[]) { n=N; for(int i=0;i<n;i++){ vx[i]=ll(x[i]); vy[i]=ll(y[i]); } return solve(); } int updateX(int pos, int val) { vx[pos]=ll(val); return solve(); } int updateY(int pos, int val) { vy[pos]=ll(val); return solve(); } /* 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() { int n; cin>>n; int X[n], Y[n]; for(int i=0;i<n;i++){ int x; cin>>X[i]; } for(int i=0;i<n;i++){ int y; cin>>Y[i]; } //fprintf(_outputFile,"%d\n",init(n,X,Y)); cout<<init(n, X, Y)<<endl; int m; cin>>m; for(int i=1;i<=m;i++){ int x, pos, val; cin>>x>>pos>>val; if(x==1){ cout<<updateX(pos, val)<<endl; }else cout<<updateY(pos, val)<<endl; } return 0; } */

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:43:17: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
     return solve();
            ~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:48:14: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return solve();
         ~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:53:14: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return solve();
         ~~~~~^~
#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...