제출 #708148

#제출 시각아이디문제언어결과실행 시간메모리
708148arcaneBigger segments (IZhO19_segments)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define mp make_pair int32_t main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, ans = 0, tmp1 = -1e8, tot, pos; cin >> n; int arr[n], smol[n], pref[n + 1]; for (int i = 0; i < n; i++) cin >> arr[i]; pref[0] = 0; set <pair <int, int> > s; for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + arr[i]; for (int i = 0; i < n; i++){ smol[i] = pref[i + 1]; auto it = s.upper_bound(mp(pref[i + 1], (int)1e18)); if (it != s.begin()){ it--; smol[i] = min(smol[i], pref[i + 1] + (*it).se); } s.insert(mp(smol[i] + pref[i + 1], -pref[i + 1])); while ((*(s.rbegin())).se != -pref[i + 1]) s.erase(--s.end()); } tot = pref[n] - smol[n - 1]; pos = n - 1; ans = 1; while (tot){ while (pref[pos + 1] != tot){ pos--; } tot -= smol[pos]; ans += 1; } cout << ans << '\n'; }

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

segments.cpp: In function 'int32_t main()':
segments.cpp:19:47: error: 'const struct std::pair<long long int, long long int>' has no member named 'se'
   19 |    smol[i] = min(smol[i], pref[i + 1] + (*it).se);
      |                                               ^~
segments.cpp:22:26: error: 'const struct std::pair<long long int, long long int>' has no member named 'se'
   22 |   while ((*(s.rbegin())).se != -pref[i + 1]) s.erase(--s.end());
      |                          ^~
segments.cpp:8:18: warning: unused variable 'tmp1' [-Wunused-variable]
    8 |  int n, ans = 0, tmp1 = -1e8, tot, pos; cin >> n;
      |                  ^~~~