제출 #689747

#제출 시각아이디문제언어결과실행 시간메모리
689747zeroesandonesDischarging (NOI20_discharging)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef long double ld; typedef vector<ll> vi; typedef pair<ll, ll> pi; #define for(i, j, k) for (ll i = j; i < (ll) k; ++i) #define ford(i, j, k) for (ll i = j; i >= (ll) k; --i) #define nl "\n" #define sp " " #define all(x) (x).begin(), (x).end() #define sc second #define fr first #define pb emplace_back const ll inf = 1e15; void solve() { ll n; cin >> n; ll t[n + 1]; for(i, 1, n + 1) cin >> t[i]; ll dp[n + 1] = {}; for(i, 1, n + 1) { dp[i] = inf; ll mx = 0; ford(j, i, 1) { mx = max(mx, t[j]); dp[i] = min(dp[i], dp[j - 1] + (n - j + 1) * mx); } } cout << dp[n] << nl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(null); ll t = 1; // cin >> t; while (t--) { solve(); } }

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

Discharging.cpp:34:21: error: macro "for" requires 3 arguments, but only 1 given
   34 |         ford(j, i, 1) {
      |                     ^
Discharging.cpp:9: note: macro "for" defined here
    9 | #define for(i, j, k) for (ll i = j; i < (ll) k; ++i)
      | 
Discharging.cpp: In function 'void solve()':
Discharging.cpp:34:23: error: expected '(' before '{' token
   34 |         ford(j, i, 1) {
      |                       ^
      |                       (
Discharging.cpp:34:23: error: expected primary-expression before '{' token
Discharging.cpp:38:5: error: expected primary-expression before '}' token
   38 |     }
      |     ^
Discharging.cpp:37:10: error: expected ';' before '}' token
   37 |         }
      |          ^
      |          ;
   38 |     }
      |     ~     
Discharging.cpp:38:5: error: expected primary-expression before '}' token
   38 |     }
      |     ^
Discharging.cpp:37:10: error: expected ')' before '}' token
   37 |         }
      |          ^
      |          )
   38 |     }
      |     ~     
Discharging.cpp:34:23: note: to match this '('
   34 |         ford(j, i, 1) {
      |                       ^
Discharging.cpp:38:5: error: expected primary-expression before '}' token
   38 |     }
      |     ^
Discharging.cpp:33:12: warning: unused variable 'mx' [-Wunused-variable]
   33 |         ll mx = 0;
      |            ^~
Discharging.cpp: In function 'int main()':
Discharging.cpp:46:13: error: 'null' was not declared in this scope; did you mean 'll'?
   46 |     cin.tie(null);
      |             ^~~~
      |             ll