제출 #219974

#제출 시각아이디문제언어결과실행 시간메모리
219974youssefbou62말 (IOI15_horses)C++14
0 / 100
20 ms9856 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 ; ll suf[MAXN],X[MAXN],Y[MAXN],N; ll product[MAXN] ; ll answer(){ ll ans = 0 ; ll prod = 1 ; for(int i = 0 ; i < N ; i++ ){ prod *= X[i] ; if( Y[i] == suf[i] ){ if( suf[i+1]*product[i+1] > Y[i]){ ans += (prod-1) * Y[i] ; ans %= MOD ; prod = 1 ; } else { ans += prod * Y[i] ; ans %= MOD ; prod = 0 ; } } } return ans; } void constructSuffix(){ product[N] = 1 ; for(int i = N-1 ; i >= 0 ; i-- ){ suf[i] = max(suf[i+1],Y[i]) ; product[i] = X[i]*product[i+1] ; } } 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; // } // }

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In function 'void constructSuffix()':
horses.cpp:49:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  for(int i = N-1 ; i >= 0 ; i-- ){
              ~^~
#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...