Submission #206112

# Submission time Handle Problem Language Result Execution time Memory
206112 2020-03-02T09:26:06 Z Segtree Horses (IOI15_horses) C++14
34 / 100
1500 ms 16044 KB
#include"horses.h"
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x,begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
ll N,X[500010],Y[500010];
int solve(){
	ll id=N-1,t=X[N-1];
	for(int i=N-2;i>=0;i--){
		if(t*Y[id]<Y[i])id=i,t=1;
		t*=X[i];
		if(t>(ll)2e9)break;
	}
	ll ans=1;
	for(int i=0;i<=id;i++)ans=ans*X[i]%mod;
	ans=ans*Y[id]%mod;
	return ans;
}
int init(int n,int x[],int y[]){
	N=n;
	rep(i,N)X[i]=x[i],Y[i]=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();
}/*
int main(){
	cin>>N;
	rep(i,N)cin>>X[i];
	rep(i,N)cin>>Y[i];
	N=1000;
	rep(i,N)X[i]=1;
	rep(i,N)Y[i]=rand()%(ll)1e9+1;
	cout<<init(N,X,Y)<<endl;
	while(1){
		string type; ll pos,val;
		cin>>type>>pos>>val;
		if(type=="X")cout<<updateX(pos,val)<<endl;
		if(type=="Y")cout<<updateY(pos,val)<<endl;
	}
	
}*/



Compilation message

horses.cpp: In function 'int solve()':
horses.cpp:17:13: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  for(int i=N-2;i>=0;i--){
            ~^~
horses.cpp:25:9: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
  return ans;
         ^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 380 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 4 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 4 ms 380 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 380 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 10 ms 376 KB Output is correct
24 Correct 11 ms 376 KB Output is correct
25 Correct 11 ms 380 KB Output is correct
26 Correct 11 ms 376 KB Output is correct
27 Correct 11 ms 376 KB Output is correct
28 Correct 11 ms 376 KB Output is correct
29 Correct 15 ms 380 KB Output is correct
30 Correct 12 ms 376 KB Output is correct
31 Correct 11 ms 376 KB Output is correct
32 Correct 14 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1587 ms 12120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 4 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 380 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 11 ms 376 KB Output is correct
24 Correct 12 ms 376 KB Output is correct
25 Correct 11 ms 376 KB Output is correct
26 Correct 12 ms 376 KB Output is correct
27 Correct 11 ms 376 KB Output is correct
28 Correct 10 ms 376 KB Output is correct
29 Correct 15 ms 376 KB Output is correct
30 Correct 11 ms 376 KB Output is correct
31 Correct 13 ms 376 KB Output is correct
32 Correct 13 ms 376 KB Output is correct
33 Execution timed out 1508 ms 16044 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 380 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 380 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 4 ms 380 KB Output is correct
23 Correct 11 ms 376 KB Output is correct
24 Correct 10 ms 504 KB Output is correct
25 Correct 11 ms 376 KB Output is correct
26 Correct 10 ms 376 KB Output is correct
27 Correct 11 ms 376 KB Output is correct
28 Correct 11 ms 376 KB Output is correct
29 Correct 15 ms 376 KB Output is correct
30 Correct 12 ms 376 KB Output is correct
31 Correct 10 ms 380 KB Output is correct
32 Correct 13 ms 376 KB Output is correct
33 Execution timed out 1567 ms 14304 KB Time limit exceeded
34 Halted 0 ms 0 KB -