답안 #1004391

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1004391 2024-06-21T08:29:33 Z vjudge1 말 (IOI15_horses) C++17
17 / 100
1500 ms 14332 KB
#include "horses.h"
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int n;
vector<ll> x, y;
ll calc(){
	ll ma = 0;
	ll prmult = 1, prmod = -1, nmod = 0;
	for (int i = 0; i < n; i++){
		prmult *= x[i];
		if (prmult >= mod){
			prmult %= mod;
			prmod = nmod;
			prmod %= mod;
			nmod = 0;
		}
		ll res;
		if (prmod != -1){
			ll res = 1ll * (mod + prmult) * y[i];
			nmod = max(nmod, res);
		}
		else{
			ll res = 1ll * prmult * y[i];
			nmod = max(nmod, res);
		}
		
	}
	return max(prmod, nmod) % mod;
}
int init(int N, int X[], int Y[]) {
	n = N;
	x.resize(N), y.resize(N);
	for (int i = 0; i < N; i++){
		x[i] = X[i];
		y[i] = Y[i];
	}
	return calc();
}

int updateX(int pos, int val){	
	x[pos] = val;
	return calc();
}

int updateY(int pos, int val) {
	y[pos] = val;
	return calc();
}

Compilation message

horses.cpp: In function 'long long int calc()':
horses.cpp:21:7: warning: declaration of 'res' shadows a previous local [-Wshadow]
   21 |    ll res = 1ll * (mod + prmult) * y[i];
      |       ^~~
horses.cpp:19:6: note: shadowed declaration is here
   19 |   ll res;
      |      ^~~
horses.cpp:25:7: warning: declaration of 'res' shadows a previous local [-Wshadow]
   25 |    ll res = 1ll * prmult * y[i];
      |       ^~~
horses.cpp:19:6: note: shadowed declaration is here
   19 |   ll res;
      |      ^~~
horses.cpp:19:6: warning: unused variable 'res' [-Wunused-variable]
horses.cpp:9:5: warning: unused variable 'ma' [-Wunused-variable]
    9 |  ll ma = 0;
      |     ^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:39:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   39 |  return calc();
      |         ~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:44:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   44 |  return calc();
      |         ~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:49:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   49 |  return calc();
      |         ~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Incorrect 0 ms 348 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1569 ms 14332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Incorrect 0 ms 344 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Incorrect 0 ms 344 KB Output isn't correct
23 Halted 0 ms 0 KB -