Submission #219969

# Submission time Handle Problem Language Result Execution time Memory
219969 2020-04-06T18:21:07 Z youssefbou62 Horses (IOI15_horses) C++14
0 / 100
22 ms 10624 KB
#include  <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }

const int MAXN = 1e3+5; 
const ll MOD = 1e9+7 ; 
int suf[MAXN],X[MAXN],Y[MAXN],N; 

ll answer(){
	ll ans = 0 ; 
	ll prod = 1 ; 
	for(int i = 0 ; i < N ; i++ ){
		prod *= X[i] ;
		if( Y[i] == suf[i] ){
			ans += prod * Y[i] ; 
			ans %= MOD ; 
			prod = 0 ;
		}   
	}
	return ans; 
}

void constructSuffix(){ 
	for(int i = N-1 ; i >= 0 ; i-- ){
		suf[i] = max(suf[i+1],Y[i]) ; 
	}
}
void init(int n,int x[],int y[]){
	N = n ; 
	for(int i = 0 ; i < n ; i++ ){
		X[i] = x[i] ; 
		Y[i] = y[i] ; 
	}
}

ll updateX(int pos , int val ){
	X[pos]=val ; 
	// constructSuffix();
	return answer() ;  
}

ll updateY(int pos , int val ){
	Y[pos] = val ; 
	constructSuffix();
	return answer() ; 
}

// int main(){
// 	int m ; 
// 	cin >> m ; 
// 	cin >> N ; 
// 	for(int i = 0; i < N ; i++ ){
// 		cin >> X[i] ; 
// 	}
// 	for(int i = 0; i < N ; i++ ){
// 		cin >> Y[i] ; 
// 	}

// 	while ( m-- ){
// 		char c ; 
// 		cin >> c ; 
// 		int p , v ; cin >> p >> v ; 
// 		cout << answer <<" = " << (( c == 'Y' )?updateY(p,v):updateX(p,v)) <<endl;  
// 	}
	
// }
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 22 ms 10624 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -