제출 #577875

#제출 시각아이디문제언어결과실행 시간메모리
577875Trisanu_DasArt Exhibition (JOI18_art)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<pair<int, int>> a(n); for (auto p : v) cin >> p.first >> p.second; sort(a.begin(), a.end()); int pref[n + 1] for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + v[i][1]; vector diff(pref + 1, pref + n + 1); for (int i = 0; i < n; i++) diff[i] -= v[i][0]; long ans = 0, tmp = INT_MIN / 2; for (int i = n - 1; i > -1; i--) { tmp = max(tmp, diff[i]); ans = max(ans, tmp + v[i][0] - pref[i]); } cout << ans << '\n'; }

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

art.cpp: In function 'int main()':
art.cpp:7:19: error: 'v' was not declared in this scope
    7 |     for (auto p : v) cin >> p.first >> p.second;
      |                   ^
art.cpp:10:5: error: expected initializer before 'for'
   10 |     for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + v[i][1];
      |     ^~~
art.cpp:10:21: error: 'i' was not declared in this scope
   10 |     for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + v[i][1];
      |                     ^
art.cpp:11:17: error: 'pref' was not declared in this scope
   11 |     vector diff(pref + 1, pref + n + 1);
      |                 ^~~~
art.cpp:12:44: error: 'v' was not declared in this scope
   12 |     for (int i = 0; i < n; i++) diff[i] -= v[i][0];
      |                                            ^
art.cpp:16:55: error: 'v' was not declared in this scope
   16 |         tmp = max(tmp, diff[i]); ans = max(ans, tmp + v[i][0] - pref[i]);
      |                                                       ^