#include <stdio.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt")
#define ll long long
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);
const int mod = 1e9 + 7;
void max_self(int& a, int b) {
a = max(a, b);
}
int add(int a, int b) {
a += b;
if(a > mod) {
a -= mod;
}
return a;
}
int mul(int a, int b) {
a = (ll)a * b % mod;
return a;
}
const int N = 1e3 + 1;
int n;
int x[N], y[N];
int solve() {
ll h = 1, p = 1, ans = 0;
long double l = 0;
for(int i = 0; i < n; ++i) {
h *= x[i];
p = mul(p, x[i]);
long double profit = (long double)y[i] * h;
if(profit > l) {
ans = mul(p, y[i]); h = 1;
l = y[i];
}
}
return ans;
}
int init(int n_, int x_[], int y_[]) {
n = 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();
}
// static char buffer[1024];
// static int currentChar = 0;
// static int charsNumber = 0;
// static inline int read() {
// if (charsNumber < 0) {
// exit(1);
// }
// if (!charsNumber || currentChar == charsNumber) {
// charsNumber = (int)fread(buffer, sizeof(buffer[0]), sizeof(buffer), stdin);
// currentChar = 0;
// }
// if (charsNumber <= 0) {
// return -1;
// }
// return buffer[currentChar++];
// }
// static inline int readInt() {
// int x; cin >> x;
// return x;
// }
// int main() {
// 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();
// }
// printf("%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) {
// printf("%d\n", updateX(pos, val));
// } else if (type == 2) {
// printf("%d\n", updateY(pos, val));
// }
// }
// return 0;
// }
Compilation message
horses.cpp: In function 'int mul(int, int)':
horses.cpp:34:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
34 | a = (ll)a * b % mod;
| ~~~~~~~~~~^~~~~
horses.cpp: In function 'int solve()':
horses.cpp:48:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
48 | p = mul(p, x[i]);
| ^
horses.cpp:51:14: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
51 | ans = mul(p, y[i]); h = 1;
| ^
horses.cpp:55:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
55 | return ans;
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
5 ms |
212 KB |
Output is correct |
24 |
Correct |
6 ms |
256 KB |
Output is correct |
25 |
Correct |
6 ms |
212 KB |
Output is correct |
26 |
Correct |
6 ms |
324 KB |
Output is correct |
27 |
Correct |
5 ms |
212 KB |
Output is correct |
28 |
Correct |
5 ms |
324 KB |
Output is correct |
29 |
Correct |
5 ms |
212 KB |
Output is correct |
30 |
Correct |
6 ms |
212 KB |
Output is correct |
31 |
Correct |
5 ms |
212 KB |
Output is correct |
32 |
Correct |
5 ms |
320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
11 ms |
8320 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
5 ms |
212 KB |
Output is correct |
24 |
Correct |
5 ms |
316 KB |
Output is correct |
25 |
Correct |
6 ms |
316 KB |
Output is correct |
26 |
Correct |
6 ms |
316 KB |
Output is correct |
27 |
Correct |
5 ms |
292 KB |
Output is correct |
28 |
Correct |
6 ms |
212 KB |
Output is correct |
29 |
Correct |
5 ms |
316 KB |
Output is correct |
30 |
Correct |
5 ms |
320 KB |
Output is correct |
31 |
Correct |
5 ms |
212 KB |
Output is correct |
32 |
Correct |
5 ms |
320 KB |
Output is correct |
33 |
Runtime error |
18 ms |
8312 KB |
Execution killed with signal 11 |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
224 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
328 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
5 ms |
212 KB |
Output is correct |
24 |
Correct |
5 ms |
212 KB |
Output is correct |
25 |
Correct |
5 ms |
212 KB |
Output is correct |
26 |
Correct |
6 ms |
212 KB |
Output is correct |
27 |
Correct |
5 ms |
212 KB |
Output is correct |
28 |
Correct |
6 ms |
212 KB |
Output is correct |
29 |
Correct |
5 ms |
212 KB |
Output is correct |
30 |
Correct |
5 ms |
212 KB |
Output is correct |
31 |
Correct |
5 ms |
212 KB |
Output is correct |
32 |
Correct |
5 ms |
212 KB |
Output is correct |
33 |
Runtime error |
11 ms |
8356 KB |
Execution killed with signal 11 |
34 |
Halted |
0 ms |
0 KB |
- |