Submission #1088721

# Submission time Handle Problem Language Result Execution time Memory
1088721 2024-09-14T21:55:17 Z gustavo_d Horses (IOI15_horses) C++17
17 / 100
1500 ms 12172 KB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXN = 500000;
const ll MOD = 1e9+7;
int n;
vector<ll> x(MAXN), y(MAXN);

int init(int N, int X[], int Y[]) {
	n = N+1;
	for (int i=1; i<n; i++) x[i] = (ll)X[i-1];
	for (int i=1; i<n; i++) y[i] = (ll)Y[i-1];

	ll ans = 0;
	ll qtd = 1;
	for (int i=1; i<n; i++) {
		qtd = (qtd * x[i]) % MOD;
		ans = max(ans, (qtd * y[i]) % MOD);
	}
	return ans;
	// int dp[n][MX_COW+1];
	// for (int i=1; i<=MX_COW; i++) {
	// 	dp[0][i] = -1e9;
	// }
	// dp[0][1] = 0;
	// for (int i=1; i<n; i++) {
	// 	for (int cow=0; cow<=MX_COW; cow++) {
	// 		dp[i][cow] = -1e9;
	// 		for (int v=0; v<=MX_COW; v++) {
	// 			if ((cow+v)/x[i] > MX_COW) continue;
	// 			if ((cow+v) % x[i] != 0) continue;
	// 			dp[i][cow] = max(
	// 				dp[i][cow],
	// 				dp[i-1][(cow + v) / x[i]] + v * y[i]
	// 			);
	// 		}
	// 	}
	// }
	// return dp[n-1][0];
}

int updateX(int pos, int val) {	
	x[pos+1] = val;
	ll ans = 0;
	ll qtd = 1;
	for (int i=1; i<n; i++) {
		qtd = (qtd * x[i]) % MOD;
		ans = max(ans, (qtd * y[i]) % MOD);
	}
	return ans;
}

int updateY(int pos, int val) {
	y[pos+1] = val;
	ll ans = 0;
	ll qtd = 1;
	for (int i=1; i<n; i++) {
		qtd = (qtd * x[i]) % MOD;
		ans = max(ans, (qtd * y[i]) % MOD);
	}
	return ans;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:23:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   23 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:53:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   53 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:64:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   64 |  return ans;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8028 KB Output is correct
2 Correct 3 ms 8028 KB Output is correct
3 Correct 3 ms 8028 KB Output is correct
4 Correct 3 ms 8028 KB Output is correct
5 Correct 3 ms 8028 KB Output is correct
6 Correct 3 ms 8028 KB Output is correct
7 Correct 3 ms 8028 KB Output is correct
8 Correct 3 ms 8028 KB Output is correct
9 Correct 3 ms 8028 KB Output is correct
10 Correct 3 ms 8028 KB Output is correct
11 Correct 3 ms 8028 KB Output is correct
12 Correct 3 ms 8028 KB Output is correct
13 Correct 3 ms 8028 KB Output is correct
14 Correct 3 ms 8028 KB Output is correct
15 Correct 3 ms 8024 KB Output is correct
16 Correct 3 ms 8028 KB Output is correct
17 Correct 3 ms 8028 KB Output is correct
18 Correct 3 ms 8028 KB Output is correct
19 Correct 3 ms 8028 KB Output is correct
20 Correct 3 ms 8228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8124 KB Output is correct
2 Correct 3 ms 8024 KB Output is correct
3 Correct 4 ms 8028 KB Output is correct
4 Correct 3 ms 8028 KB Output is correct
5 Correct 3 ms 8120 KB Output is correct
6 Correct 5 ms 8028 KB Output is correct
7 Correct 3 ms 8028 KB Output is correct
8 Correct 3 ms 8028 KB Output is correct
9 Correct 3 ms 8028 KB Output is correct
10 Correct 5 ms 8028 KB Output is correct
11 Correct 3 ms 8184 KB Output is correct
12 Correct 3 ms 8028 KB Output is correct
13 Correct 3 ms 8028 KB Output is correct
14 Correct 3 ms 8028 KB Output is correct
15 Correct 3 ms 8028 KB Output is correct
16 Correct 5 ms 8028 KB Output is correct
17 Correct 4 ms 8028 KB Output is correct
18 Correct 3 ms 8028 KB Output is correct
19 Correct 4 ms 8028 KB Output is correct
20 Correct 3 ms 8028 KB Output is correct
21 Incorrect 3 ms 8028 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1576 ms 12172 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 3 ms 8028 KB Output is correct
3 Correct 3 ms 8028 KB Output is correct
4 Correct 3 ms 8028 KB Output is correct
5 Correct 3 ms 8028 KB Output is correct
6 Correct 3 ms 8028 KB Output is correct
7 Correct 3 ms 8028 KB Output is correct
8 Correct 3 ms 8028 KB Output is correct
9 Correct 3 ms 8080 KB Output is correct
10 Correct 3 ms 8028 KB Output is correct
11 Correct 3 ms 8028 KB Output is correct
12 Correct 3 ms 8028 KB Output is correct
13 Correct 3 ms 8028 KB Output is correct
14 Correct 4 ms 8028 KB Output is correct
15 Correct 3 ms 8028 KB Output is correct
16 Correct 3 ms 8028 KB Output is correct
17 Correct 3 ms 8028 KB Output is correct
18 Correct 3 ms 8028 KB Output is correct
19 Correct 3 ms 8028 KB Output is correct
20 Correct 3 ms 8028 KB Output is correct
21 Incorrect 3 ms 8028 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8028 KB Output is correct
2 Correct 3 ms 8028 KB Output is correct
3 Correct 3 ms 8028 KB Output is correct
4 Correct 3 ms 8028 KB Output is correct
5 Correct 3 ms 8176 KB Output is correct
6 Correct 3 ms 8268 KB Output is correct
7 Correct 3 ms 8280 KB Output is correct
8 Correct 3 ms 8028 KB Output is correct
9 Correct 4 ms 8028 KB Output is correct
10 Correct 3 ms 8028 KB Output is correct
11 Correct 3 ms 8024 KB Output is correct
12 Correct 3 ms 8028 KB Output is correct
13 Correct 3 ms 8052 KB Output is correct
14 Correct 4 ms 8028 KB Output is correct
15 Correct 3 ms 8028 KB Output is correct
16 Correct 3 ms 8028 KB Output is correct
17 Correct 3 ms 8028 KB Output is correct
18 Correct 3 ms 8116 KB Output is correct
19 Correct 3 ms 8280 KB Output is correct
20 Correct 5 ms 8028 KB Output is correct
21 Incorrect 4 ms 8028 KB Output isn't correct
22 Halted 0 ms 0 KB -