Submission #219969

#TimeUsernameProblemLanguageResultExecution timeMemory
219969youssefbou62Horses (IOI15_horses)C++14
0 / 100
22 ms10624 KiB
#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 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...