제출 #109095

#제출 시각아이디문제언어결과실행 시간메모리
109095Garu말 (IOI15_horses)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
typedef long long ll;
int x[MAXN] , y[MAXN];
int n;
int updateX(int pos,int val)
{
x[pos] = val;
ll ans = x[0] * y[0];
ans%=MOD;
ll profit = 0;
ll horses = 1;

for(int i = 1 ; i < n ; i++)
{
	horses = (horses % MOD * x[i] % MOD) % MOD;
	horses%=MOD;
	profit = (horses % MOD * y[i] % MOD) % MOD;
	ans = max(ans , profit);
}

return (int)ans;


}

int updateY(int pos,int val)
{

y[pos] = val;

ll ans = (y[0] * x[0]);
ans%=MOD;
ll profit = 0;
ll horses = x[0]

for(int i = 1 ; i < n ; i++)
{
	horses = (horses % MOD * x[i] % MOD) % MOD;
	horses%=MOD;
	profit = (horses % MOD * y[i] % MOD) % MOD;
	ans = max(ans , profit);
}

return (int)ans;

}

int init(int N , int X[] , int Y[])
{
n = N;
ll ans = x[0] * y[0];
ans%=MOD;
ll profit = 0;
ll horses = 1;
for(int  i = 0 ; i < n ; i++)
 {
     x[i] = X[i];
     y[i] = Y[i];
 }
for(int i = 1 ; i < n ; i++)
{
	horses = (horses % MOD * x[i] % MOD) % MOD;
	horses%=MOD;
	profit = (horses % MOD * y[i] % MOD) % MOD;
	ans = max(ans , profit);
}

return (int)ans;

}
 

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

horses.cpp: In function 'int updateY(int, int)':
horses.cpp:40:1: error: expected ',' or ';' before 'for'
 for(int i = 1 ; i < n ; i++)
 ^~~
horses.cpp:40:17: error: 'i' was not declared in this scope
 for(int i = 1 ; i < n ; i++)
                 ^
horses.cpp:37:4: warning: unused variable 'profit' [-Wunused-variable]
 ll profit = 0;
    ^~~~~~
horses.cpp:38:4: warning: unused variable 'horses' [-Wunused-variable]
 ll horses = x[0]
    ^~~~~~