제출 #391585

#제출 시각아이디문제언어결과실행 시간메모리
391585l3nl3Growing Vegetables is Fun 4 (JOI21_ho_t1)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int mxsz = 2e5 + 10; const int inf = 1e9 + 7; int n, a[mxsz], p[mxsz], s[mxsz], mn=inf; int main () { cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; p[i] = p[i-1] + max(0, 1-(a[i] - a[i-1];)); } for (int i = n; i >= 1; i--) { s[i] = s[i+1] + max(0, (a[i+1] - a[i]) + 1); } for (int i = 1; i <= n; i++) { mn = min(mn, max(p[i], s[i])); } cout << mn; }

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

Main.cpp: In function 'int main()':
Main.cpp:14:48: error: expected ')' before ';' token
   14 |         p[i] = p[i-1] + max(0, 1-(a[i] - a[i-1];));
      |                                  ~             ^
      |                                                )
Main.cpp:14:48: error: expected ')' before ';' token
   14 |         p[i] = p[i-1] + max(0, 1-(a[i] - a[i-1];));
      |                            ~                   ^
      |                                                )
Main.cpp:14:49: error: expected primary-expression before ')' token
   14 |         p[i] = p[i-1] + max(0, 1-(a[i] - a[i-1];));
      |                                                 ^