제출 #1081269

#제출 시각아이디문제언어결과실행 시간메모리
1081269DeathIsAweGrowing Vegetables is Fun 4 (JOI21_ho_t1)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long; int leftside[200001], rightside[200001]; int32_t main() { int n; cin >> n; vector<int> arr(n); for (int i=0;i<n;i++) { cin >> arr[i]; } leftside[0] = 0; for (int i=1;i<n;i++) { leftside[i] = leftside[i-1] + max(arr[i-1] - arr[i] + 1, 0); } rightside[n-1] = 0; for (int i=n-2;i>-1;i--) { rightside[i] = rightside[i+1] + max(arr[i+1] - arr[i] + 1, 0); } int ans = INT_MAX, curans; if (leftside[n-1] > rightside[0]) { ans = rightside[0]; } else { ans = leftside[n-1]; } for (int i=1;i<n-1;i++) { curans = leftside[i-1] + rightside[i+1]; if (arr[i+1] - arr[i] - leftside[i-1] > arr[i-1] - arr[i] - rightside[i+1]) { curans += max(arr[i+1] - arr[i] - leftside[i-1] + 1, 0); } else { curans += max(arr[i-1] - arr[i] - rightside[i+1] + 1, 0); } if (curans < ans) { ans = curans; } } cout << ans; }

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

Main.cpp:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
Main.cpp:4:1: note: in expansion of macro 'int'
    4 | int leftside[200001], rightside[200001];
      | ^~~
Main.cpp:4:5: error: 'leftside' does not name a type
    4 | int leftside[200001], rightside[200001];
      |     ^~~~~~~~
Main.cpp: In function 'int32_t main()':
Main.cpp:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
Main.cpp:8:5: note: in expansion of macro 'int'
    8 |     int n; cin >> n;
      |     ^~~
Main.cpp:8:9: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |     int n; cin >> n;
      |         ^
      |         yn
Main.cpp:3:18: error: template argument 1 is invalid
    3 | #define int long long;
      |                  ^~~~
Main.cpp:9:12: note: in expansion of macro 'int'
    9 |     vector<int> arr(n);
      |            ^~~
Main.cpp:3:18: error: template argument 2 is invalid
    3 | #define int long long;
      |                  ^~~~
Main.cpp:9:12: note: in expansion of macro 'int'
    9 |     vector<int> arr(n);
      |            ^~~
Main.cpp:9:15: error: expected primary-expression before '>' token
    9 |     vector<int> arr(n);
      |               ^
Main.cpp:9:17: error: 'arr' was not declared in this scope
    9 |     vector<int> arr(n);
      |                 ^~~
Main.cpp:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
Main.cpp:10:10: note: in expansion of macro 'int'
   10 |     for (int i=0;i<n;i++) {
      |          ^~~
Main.cpp:10:14: error: 'i' was not declared in this scope
   10 |     for (int i=0;i<n;i++) {
      |              ^
Main.cpp:10:21: error: expected ')' before ';' token
   10 |     for (int i=0;i<n;i++) {
      |         ~           ^
      |                     )
Main.cpp:10:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   10 |     for (int i=0;i<n;i++) {
      |     ^~~
Main.cpp:10:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   10 |     for (int i=0;i<n;i++) {
      |                      ^
Main.cpp:10:22: error: 'i' was not declared in this scope
Main.cpp:15:5: error: 'leftside' was not declared in this scope
   15 |     leftside[0] = 0;
      |     ^~~~~~~~
Main.cpp:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
Main.cpp:16:10: note: in expansion of macro 'int'
   16 |     for (int i=1;i<n;i++) {
      |          ^~~
Main.cpp:16:21: error: expected ')' before ';' token
   16 |     for (int i=1;i<n;i++) {
      |         ~           ^
      |                     )
Main.cpp:16:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   16 |     for (int i=1;i<n;i++) {
      |     ^~~
Main.cpp:16:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   16 |     for (int i=1;i<n;i++) {
      |                      ^
Main.cpp:19:5: error: 'rightside' was not declared in this scope
   19 |     rightside[n-1] = 0;
      |     ^~~~~~~~~
Main.cpp:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
Main.cpp:20:10: note: in expansion of macro 'int'
   20 |     for (int i=n-2;i>-1;i--) {
      |          ^~~
Main.cpp:20:24: error: expected ')' before ';' token
   20 |     for (int i=n-2;i>-1;i--) {
      |         ~              ^
      |                        )
Main.cpp:20:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   20 |     for (int i=n-2;i>-1;i--) {
      |     ^~~
Main.cpp:20:25: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   20 |     for (int i=n-2;i>-1;i--) {
      |                         ^
Main.cpp:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
Main.cpp:25:5: note: in expansion of macro 'int'
   25 |     int ans = INT_MAX, curans;
      |     ^~~
Main.cpp:25:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   25 |     int ans = INT_MAX, curans;
      |         ^~~
      |         abs
Main.cpp:25:24: error: 'curans' was not declared in this scope; did you mean 'wctrans'?
   25 |     int ans = INT_MAX, curans;
      |                        ^~~~~~
      |                        wctrans
Main.cpp:3:18: error: declaration does not declare anything [-fpermissive]
    3 | #define int long long;
      |                  ^~~~
Main.cpp:31:10: note: in expansion of macro 'int'
   31 |     for (int i=1;i<n-1;i++) {
      |          ^~~
Main.cpp:31:23: error: expected ')' before ';' token
   31 |     for (int i=1;i<n-1;i++) {
      |         ~             ^
      |                       )
Main.cpp:31:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   31 |     for (int i=1;i<n-1;i++) {
      |     ^~~
Main.cpp:31:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   31 |     for (int i=1;i<n-1;i++) {
      |                        ^