Submission #792077

# Submission time Handle Problem Language Result Execution time Memory
792077 2023-07-24T14:51:24 Z acatmeowmeow Horses (IOI15_horses) C++11
34 / 100
1500 ms 15860 KB
#include "horses.h"
#include <bits/stdc++.h>

using namespace std;

#define int long long 

const int NMAX = 5e5, modulo = 1e9 + 7;
int n, x[NMAX + 5], y[NMAX + 5];

int compute() {
	int index = n - 1;
	for (int i = n - 2; i >= 0; i--) {
		int res = y[index], j = i + 1;
		while (res <= y[i] && j <= index) res *= x[j++];
		if (res <= y[i]) index = i;
	}
	int ans = 1;
	for (int i = 0; i <= index; i++) ans *= x[i], ans %= modulo;
	ans *= y[index], ans %= modulo;
	return ans;
}

signed init(signed N, signed X[], signed Y[]) {
	n = N;
	for (int i = 0; i < n; i++) x[i] = X[i], y[i] = Y[i];
	return compute();
}

signed updateX(signed pos, signed val) {	
	x[pos] = val;
	return compute();
}

signed updateY(signed pos, signed val) {
	y[pos] = val;
	return compute();
}

/*signed main() {
	//_inputFile = fopen("horses.in", "rb");
	//_outputFile = fopen("horses.out", "w");

	signed N;
	cin >> N;

	signed *X = (signed*)malloc(sizeof(signed)*(unsigned)N);
	signed *Y = (signed*)malloc(sizeof(signed)*(unsigned)N);

	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}

	for (int i = 0; i < N; i++) {
		cin >> Y[i];
	}

	//fprintf(_outputFile,"%d\n",init(N,X,Y));
	cout << init(N, X, Y) << '\n';

	signed M;
	cin >> M;

	for (int i = 0; i < M; i++) {
		signed type; cin >> type;
		signed pos; cin >> pos;
		signed val; cin >> val;

		if (type == 1) {
			//fprintf(_outputFile,"%d\n",updateX(pos,val));
			cout << updateX(pos, val) << '\n';
		} else if (type == 2) {
			//fprintf(_outputFile,"%d\n",updateY(pos,val));
			cout << updateY(pos, val) << '\n';
		}
	}

	return 0;
}*/

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:27:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   27 |  return compute();
      |         ~~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:32:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   32 |  return compute();
      |         ~~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:37:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   37 |  return compute();
      |         ~~~~~~~^~
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 312 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 1 ms 212 KB Output is correct
14 Correct 1 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 316 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory 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 1 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 316 KB Output is correct
9 Correct 1 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 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 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 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 6 ms 340 KB Output is correct
24 Correct 6 ms 340 KB Output is correct
25 Correct 6 ms 340 KB Output is correct
26 Correct 6 ms 340 KB Output is correct
27 Correct 140 ms 340 KB Output is correct
28 Correct 6 ms 340 KB Output is correct
29 Correct 116 ms 340 KB Output is correct
30 Correct 45 ms 364 KB Output is correct
31 Correct 401 ms 340 KB Output is correct
32 Correct 211 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1562 ms 14216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 312 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 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 1 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 316 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 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
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 6 ms 360 KB Output is correct
24 Correct 6 ms 340 KB Output is correct
25 Correct 6 ms 340 KB Output is correct
26 Correct 6 ms 340 KB Output is correct
27 Correct 141 ms 340 KB Output is correct
28 Correct 6 ms 340 KB Output is correct
29 Correct 116 ms 340 KB Output is correct
30 Correct 44 ms 340 KB Output is correct
31 Correct 399 ms 340 KB Output is correct
32 Correct 218 ms 340 KB Output is correct
33 Execution timed out 1547 ms 15860 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 280 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 316 KB Output is correct
14 Correct 1 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 1 ms 312 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 6 ms 372 KB Output is correct
24 Correct 6 ms 324 KB Output is correct
25 Correct 6 ms 340 KB Output is correct
26 Correct 6 ms 340 KB Output is correct
27 Correct 141 ms 360 KB Output is correct
28 Correct 6 ms 340 KB Output is correct
29 Correct 116 ms 340 KB Output is correct
30 Correct 45 ms 340 KB Output is correct
31 Correct 398 ms 344 KB Output is correct
32 Correct 210 ms 340 KB Output is correct
33 Execution timed out 1579 ms 14204 KB Time limit exceeded
34 Halted 0 ms 0 KB -