Submission #801960

# Submission time Handle Problem Language Result Execution time Memory
801960 2023-08-02T08:42:36 Z jlallas384 Horses (IOI15_horses) C++17
0 / 100
1500 ms 12148 KB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

vector<int> x, y;
int n;

int solve(){
	int ans = 0;
	int hv = 1;
	for(int i = 0; i < n; i++){
		hv = (ll) hv * x[i] % mod;
		if(y[i] > y[i + 1]){
			ans = (ans + ll(hv - 1 + mod) % mod * y[i]) % mod;
			hv = 1;
		}
	}
	return ans;
}

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];
	}
	y.push_back(-1);
	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:14:23: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   14 |   hv = (ll) hv * x[i] % mod;
      |        ~~~~~~~~~~~~~~~^~~~~
horses.cpp:16:48: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   16 |    ans = (ans + ll(hv - 1 + mod) % mod * y[i]) % mod;
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1565 ms 12148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -