Submission #609817

# Submission time Handle Problem Language Result Execution time Memory
609817 2022-07-27T23:57:58 Z jairRS Horses (IOI15_horses) C++17
34 / 100
23 ms 12288 KB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MAXN = 1000;
const ll MOD = 1'000'000'000LL + 7LL;
ll gN, gX[MAXN], gY[MAXN];

struct bignum{
	ll val = 0;
	bool overMOD = false;
	bignum(ll _val){
		overMOD = _val/MOD > 0;
		val = _val % MOD;
	}

	void scale(ll x){
		bignum newBignum = bignum(val * x);
		overMOD |= newBignum.overMOD;
		val = newBignum.val;
	}
};

int getAns(){
	bignum curAns(gY[gN - 1] * gX[gN - 1]);
	for (int i = gN - 2; i >= 0; i--)
	{
		if(!curAns.overMOD && gY[i] > curAns.val)
			curAns = bignum(gY[i] * gX[i]);
		else{
			curAns.scale(gX[i]);
		}
	}
	return curAns.val;
}

int init(int N, int X[], int Y[]) {
	gN = N;
	for (int i = 0; i < N; i++)
	{
		gX[i] = X[i];
		gY[i] = Y[i];
	}
	
	return getAns();
}

int updateX(int pos, int val) {	
	gX[pos] = val;
	return getAns();
}

int updateY(int pos, int val) {
	gY[pos] = val;
	return getAns();
}

Compilation message

horses.cpp: In function 'int getAns()':
horses.cpp:27:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   27 |  for (int i = gN - 2; i >= 0; i--)
      |               ~~~^~~
horses.cpp:35:16: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   35 |  return curAns.val;
      |         ~~~~~~~^~~
# Verdict Execution time Memory 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 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
# Verdict Execution time Memory 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 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 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 1 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 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 0 ms 212 KB Output is correct
23 Correct 6 ms 340 KB Output is correct
24 Correct 5 ms 340 KB Output is correct
25 Correct 5 ms 364 KB Output is correct
26 Correct 5 ms 340 KB Output is correct
27 Correct 5 ms 316 KB Output is correct
28 Correct 5 ms 340 KB Output is correct
29 Correct 6 ms 212 KB Output is correct
30 Correct 7 ms 316 KB Output is correct
31 Correct 6 ms 340 KB Output is correct
32 Correct 6 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 13 ms 8404 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 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 1 ms 212 KB Output is correct
15 Correct 0 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 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 5 ms 340 KB Output is correct
24 Correct 5 ms 340 KB Output is correct
25 Correct 6 ms 360 KB Output is correct
26 Correct 5 ms 340 KB Output is correct
27 Correct 6 ms 340 KB Output is correct
28 Correct 5 ms 316 KB Output is correct
29 Correct 6 ms 212 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 6 ms 340 KB Output is correct
32 Correct 5 ms 312 KB Output is correct
33 Runtime error 23 ms 12288 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -
# 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 1 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 0 ms 212 KB Output is correct
9 Correct 0 ms 224 KB Output is correct
10 Correct 1 ms 260 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 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 5 ms 340 KB Output is correct
24 Correct 5 ms 340 KB Output is correct
25 Correct 5 ms 340 KB Output is correct
26 Correct 6 ms 340 KB Output is correct
27 Correct 5 ms 344 KB Output is correct
28 Correct 5 ms 340 KB Output is correct
29 Correct 6 ms 212 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 5 ms 340 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Runtime error 13 ms 10484 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -