Submission #231809

#TimeUsernameProblemLanguageResultExecution timeMemory
231809MasterdanHorses (IOI15_horses)C++14
17 / 100
20 ms8448 KiB
#include "horses.h" #include <bits/stdc++.h> #define MIN -1 #define MAX 1000000007 #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]; int solve(){ /* for(int i=0;i<n;i++)cout<<vx[i]<<" "; cout<<endl; for(int i=0;i<n;i++)cout<<vy[i]<<" "; cout<<endl;*/ ll acum=1; ll maxi=MIN; for(int i=0;i<n;i++){ acum*=vx[i]; acum=acum%lol; ll aux=(acum*vy[i])%lol; maxi=max(maxi, aux); } return int(maxi); } int init(int N, int x[], int y[]) { n=N; for(int i=0;i<n;i++){ vx[i]=x[i]; vy[i]=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; } */
#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...