제출 #676026

#제출 시각아이디문제언어결과실행 시간메모리
676026Hacv16말 (IOI15_horses)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
 
#define fr first
#define sc second
 
typedef long long ll;
const int MAX = 1010;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
 
int x[MAX], y[MAX];

int getAnswer(){
    int ans = 0, horses = 1;

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

    return ans;
}

int init(int _n, int _x[], int _y[]){
    n = _n; 
 
    for(int i = 1; i <= n; i++)
        x[i] = _x[i - 1], y[i] = _y[i - 1];
 
    return getAnswer();
}
 
int updateX(int pos, int val){
    x[pos + 1] = val;
    return getAnswer();
}
 
int updateY(int pos, int val){
    y[pos + 1] = val;
    return getAnswer();
}

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

horses.cpp: In function 'int getAnswer()':
horses.cpp:17:25: error: 'n' was not declared in this scope
   17 |     for(int i = 1; i <= n; i++){
      |                         ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:26:5: error: 'n' was not declared in this scope; did you mean '_n'?
   26 |     n = _n;
      |     ^
      |     _n