Submission #1088276

#TimeUsernameProblemLanguageResultExecution timeMemory
1088276dostsHorses (IOI15_horses)C++17
17 / 100
1541 ms14172 KiB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<    
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>
const int MOD = 1e9+7,inf = 2e14;
const int N = 5e5+50;

int add(int x,int y) {
	return ((x+y) >= MOD ? x+y-MOD : x+y);
}

int mult(int x,int y) {
	return ((x%MOD)*(y%MOD))%MOD;
}

int x[N],y[N];

int32_t init(int32_t N, int32_t X[], int32_t Y[]) {
	for (int i=0;i<N;i++) x[i] = X[i],y[i] = Y[i];
	int mlt = 1;
	int ans = 0;
	for (int i=0;i<N;i++) {
		mlt = mult(mlt,X[i]);
		ans = max(ans,mlt*Y[i]);
	}
	return ans;
}

int32_t updateX(int32_t pos, int32_t val) {	
	x[pos] = val;
	int mlt = 1;
	int ans = 0;
	for (int i=0;i<N;i++) {
		mlt = mult(mlt,x[i]);
		ans = max(ans,mlt*y[i]);
	}
	return ans;
}

int32_t updateY(int32_t pos, int32_t val) {
	y[pos] = val;
	int mlt = 1;
	int ans = 0;
	for (int i=0;i<N;i++) {
		mlt = mult(mlt,x[i]);
		ans = max(ans,mlt*y[i]);
	}
	return ans;
}

Compilation message (stderr)

horses.cpp: In function 'int32_t init(int32_t, int32_t*, int32_t*)':
horses.cpp:24:22: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   24 | int32_t init(int32_t N, int32_t X[], int32_t Y[]) {
      |              ~~~~~~~~^
horses.cpp:12:11: note: shadowed declaration is here
   12 | const int N = 5e5+50;
      |           ^
horses.cpp:32:9: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
   32 |  return ans;
      |         ^~~
horses.cpp: In function 'int32_t updateX(int32_t, int32_t)':
horses.cpp:43:9: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
   43 |  return ans;
      |         ^~~
horses.cpp: In function 'int32_t updateY(int32_t, int32_t)':
horses.cpp:54:9: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
   54 |  return ans;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...