Submission #935024

# Submission time Handle Problem Language Result Execution time Memory
935024 2024-02-28T12:05:38 Z PagodePaiva Horses (IOI15_horses) C++17
17 / 100
1500 ms 15956 KB
#include <bits/stdc++.h>
#include "horses.h"
#define N 500010

using namespace std;

int n;
long long v[N][2];
long long dp[N];
const long long mod = 1e9+7;
long long p = 1;

long long binpow(long long a, long long b, long long m){
	a %= m;
	if(b == 0) return 1;
	long long t = binpow(a, b/2, m);
	if(b % 2 == 0) return (t*t) % m;
	else return ((((t*t) % m)*a) % m);
}

int solve(){
	dp[0] = 0;
	long long res = 0;
	for(int i = 1;i <= n;i++){
		dp[i] = 0;
		long long int prod = 1;
		for(int j = i;j > 0;j--){
			prod *= v[j][0];
			dp[i] = max(dp[i], dp[j-1] + ((prod-1)*v[i][1]));
			res = max(res, dp[j-1] + prod*v[i][1]);
		}
		// cout << dp[i] << ' ';
	}
	return res % mod;
}

int init(int NN, int X[], int Y[]) {
	n = NN;
	for(int i = 1;i <= n;i++){
		v[i][0] = X[i-1];
		p *= v[i][0];
		p %= mod;
		v[i][1] = Y[i-1];
	}
	return solve();
}

int updateX(int pos, int val) {
	p *= binpow(v[pos+1][0], mod-2, mod);	
	p %= mod;
	v[pos+1][0] = val;
	p *= val;
	p %= mod;
	return solve();
}

int updateY(int pos, int val) {
	v[pos+1][1] = val;
	return solve();
}

Compilation message

horses.cpp: In function 'int solve()':
horses.cpp:34:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   34 |  return res % mod;
      |         ~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2456 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 0 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Incorrect 1 ms 2396 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1559 ms 15956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Incorrect 1 ms 2396 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Incorrect 1 ms 2396 KB Output isn't correct
22 Halted 0 ms 0 KB -