답안 #935025

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
935025 2024-02-28T12:06:42 Z PagodePaiva 말 (IOI15_horses) C++17
17 / 100
25 ms 14672 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(){
	if(n >= 100){
		return (p*v[n][1]) % mod;
	}
	else{
		long long aux = 1;
		for(int i = 1;i <= n;i++){
			aux *= v[i][0];
			if(aux > (long long) 1e10){
				return (p*v[n][1]) % mod;
			}
		}
	}
	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:23:22: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   23 |   return (p*v[n][1]) % mod;
      |          ~~~~~~~~~~~~^~~~~
horses.cpp:30:24: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   30 |     return (p*v[n][1]) % mod;
      |            ~~~~~~~~~~~~^~~~~
horses.cpp:46:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   46 |  return res % mod;
      |         ~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 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 0 ms 2396 KB Output is correct
8 Correct 0 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 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 0 ms 2396 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2392 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 1 ms 2396 KB Output is correct
9 Correct 0 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 2444 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 14672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2392 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 3 ms 2652 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 2396 KB Output is correct
16 Correct 0 ms 2392 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2408 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Incorrect 0 ms 2396 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 1 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 1 ms 2488 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 2392 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 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 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 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 -