답안 #597110

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
597110 2022-07-15T13:58:04 Z Apiram 말 (IOI15_horses) C++14
34 / 100
1500 ms 12216 KB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
vector<int>x,y;
int solve(){
	int N = (int)x.size();
	vector<long long>numhorse(N + 1,0);
	numhorse[0] = 1;
	for (int i = 0;i<N;++i){
		numhorse[i + 1] = (numhorse[i] * x[i])%mod;
	}
	int ans = 0;
	
	//(numhorse[i + 1] * Y[i] >  y[j] * number of horse[j + 1]
	long long maxxy = y[N - 1],index = N - 1;
	ans = (numhorse[N] * y[N - 1])%mod;
	for (int i = N - 1;i>=1;--i){
		long long temp = 1;
		bool ok = true;
		for (int j = i;j <=index;++j){
			temp = (temp * x[j]);
			if (temp > 1e9)ok = false;
		}
		//cout<<temp<<" "<<Y[i - 1] / Y[index]<<" "<<i<<" "<<maxxy<<" "<<index<<'\n';
		if (y[i - 1] > maxxy && (ok && temp * y[index] <= y[i - 1])){
			maxxy = y[i - 1];
			index = i - 1;
			ans = (numhorse[i] * y[i - 1])%mod;
		}
	}
	return ans;
}
int init(int N, int X[], int Y[]) {
	for (int i = 0;i<N;++i){
		x.push_back(X[i]);
		y.push_back(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();
}



Compilation message

horses.cpp: In function 'int solve()':
horses.cpp:17:32: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   17 |  ans = (numhorse[N] * y[N - 1])%mod;
      |        ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp:23:8: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   23 |    if (temp > 1e9)ok = false;
      |        ^~~~
horses.cpp:29:34: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   29 |    ans = (numhorse[i] * y[i - 1])%mod;
      |          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 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 1 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 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 308 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 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 523 ms 212 KB Output is correct
24 Correct 532 ms 336 KB Output is correct
25 Correct 523 ms 312 KB Output is correct
26 Correct 555 ms 312 KB Output is correct
27 Correct 494 ms 212 KB Output is correct
28 Correct 533 ms 212 KB Output is correct
29 Correct 544 ms 332 KB Output is correct
30 Correct 550 ms 316 KB Output is correct
31 Correct 498 ms 308 KB Output is correct
32 Correct 507 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1584 ms 12208 KB Time limit exceeded
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 0 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 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 526 ms 324 KB Output is correct
24 Correct 532 ms 324 KB Output is correct
25 Correct 521 ms 316 KB Output is correct
26 Correct 547 ms 440 KB Output is correct
27 Correct 495 ms 432 KB Output is correct
28 Correct 537 ms 312 KB Output is correct
29 Correct 537 ms 308 KB Output is correct
30 Correct 539 ms 316 KB Output is correct
31 Correct 497 ms 312 KB Output is correct
32 Correct 509 ms 336 KB Output is correct
33 Execution timed out 1547 ms 12216 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 224 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 0 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 529 ms 316 KB Output is correct
24 Correct 532 ms 436 KB Output is correct
25 Correct 521 ms 212 KB Output is correct
26 Correct 532 ms 320 KB Output is correct
27 Correct 494 ms 448 KB Output is correct
28 Correct 542 ms 308 KB Output is correct
29 Correct 539 ms 308 KB Output is correct
30 Correct 534 ms 324 KB Output is correct
31 Correct 523 ms 304 KB Output is correct
32 Correct 502 ms 320 KB Output is correct
33 Execution timed out 1582 ms 12216 KB Time limit exceeded
34 Halted 0 ms 0 KB -