# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
231817 |
2020-05-15T00:34:48 Z |
Masterdan |
Horses (IOI15_horses) |
C++14 |
|
29 ms |
12368 KB |
#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
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 time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
5 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
256 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
256 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
256 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
256 KB |
Output is correct |
19 |
Correct |
4 ms |
256 KB |
Output is correct |
20 |
Correct |
4 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
256 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
256 KB |
Output is correct |
13 |
Correct |
4 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
256 KB |
Output is correct |
19 |
Correct |
4 ms |
384 KB |
Output is correct |
20 |
Correct |
4 ms |
256 KB |
Output is correct |
21 |
Correct |
4 ms |
256 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
13 ms |
384 KB |
Output is correct |
24 |
Correct |
13 ms |
384 KB |
Output is correct |
25 |
Correct |
26 ms |
504 KB |
Output is correct |
26 |
Correct |
26 ms |
384 KB |
Output is correct |
27 |
Correct |
11 ms |
384 KB |
Output is correct |
28 |
Correct |
16 ms |
384 KB |
Output is correct |
29 |
Correct |
15 ms |
384 KB |
Output is correct |
30 |
Correct |
18 ms |
384 KB |
Output is correct |
31 |
Correct |
12 ms |
384 KB |
Output is correct |
32 |
Correct |
10 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
20 ms |
8464 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
368 KB |
Output is correct |
6 |
Correct |
5 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
5 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
256 KB |
Output is correct |
13 |
Correct |
4 ms |
256 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
256 KB |
Output is correct |
16 |
Correct |
5 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
256 KB |
Output is correct |
18 |
Correct |
4 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
4 ms |
256 KB |
Output is correct |
21 |
Correct |
5 ms |
256 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
13 ms |
384 KB |
Output is correct |
24 |
Correct |
13 ms |
384 KB |
Output is correct |
25 |
Correct |
26 ms |
384 KB |
Output is correct |
26 |
Correct |
26 ms |
384 KB |
Output is correct |
27 |
Correct |
12 ms |
384 KB |
Output is correct |
28 |
Correct |
15 ms |
384 KB |
Output is correct |
29 |
Correct |
15 ms |
384 KB |
Output is correct |
30 |
Correct |
18 ms |
384 KB |
Output is correct |
31 |
Correct |
10 ms |
384 KB |
Output is correct |
32 |
Correct |
10 ms |
384 KB |
Output is correct |
33 |
Runtime error |
29 ms |
12368 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
4 ms |
256 KB |
Output is correct |
6 |
Correct |
4 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
512 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
4 ms |
256 KB |
Output is correct |
16 |
Correct |
4 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
4 ms |
384 KB |
Output is correct |
20 |
Correct |
4 ms |
256 KB |
Output is correct |
21 |
Correct |
4 ms |
512 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
13 ms |
384 KB |
Output is correct |
24 |
Correct |
13 ms |
384 KB |
Output is correct |
25 |
Correct |
26 ms |
384 KB |
Output is correct |
26 |
Correct |
26 ms |
384 KB |
Output is correct |
27 |
Correct |
11 ms |
384 KB |
Output is correct |
28 |
Correct |
15 ms |
384 KB |
Output is correct |
29 |
Correct |
15 ms |
384 KB |
Output is correct |
30 |
Correct |
18 ms |
384 KB |
Output is correct |
31 |
Correct |
11 ms |
384 KB |
Output is correct |
32 |
Correct |
10 ms |
384 KB |
Output is correct |
33 |
Runtime error |
20 ms |
10496 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
34 |
Halted |
0 ms |
0 KB |
- |