Submission #652150

#TimeUsernameProblemLanguageResultExecution timeMemory
652150ymmHacker (BOI15_hac)C++17
Compilation error
0 ms0 KiB
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x) #define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x) typedef long long ll; typedef std::pair<int, int> pii; typedef std::pair<ll , ll > pll; using namespace std; const int N = 500'010; int seg[2*N]; const int inf = 1e9+10; void up(int l, int r, int x) { l += N; r += N; while (l < r) { if (l&1) { seg[l] = min(seg[l], x); ++l; } if (r&1) { --r; seg[r] = min(seg[r], x); } l /= 2; r /= 2; } } int get(int i) { i += N; int ans = inf; while (i) { ans = min(ans, seg[i]); i /= 2; } return ans; } int n; int a[N]; int pre[N]; int main() { cin.tie(0) -> sync_with_stdio(false); fill(seg, seg+2*N, inf); cin >> n; Loop (i,0,n) { cin >> a[i]; pre[i+1] = pre[i] + a[i]; } int len = (n+1)/2; Loop (i,0,n) { if (i+len <= n) { int sum = pre[i+len] - pre[i]; up(i, i+len, sum); } else { int sum = pre[n] - pre[i] + pre[i+len-n]; up(i, n, sum); up(0, i+len-n, sum); } } int ans = 0; Loop (i,0,n) ans = max(ans, get(i)); cout << ans << '\n'; }

Compilation message (stderr)

hac.cpp:4:14: error: 'pair' in namespace 'std' does not name a template type
    4 | typedef std::pair<int, int> pii;
      |              ^~~~
hac.cpp:1:1: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
  +++ |+#include <utility>
    1 | #define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
hac.cpp:5:14: error: 'pair' in namespace 'std' does not name a template type
    5 | typedef std::pair<ll , ll > pll;
      |              ^~~~
hac.cpp:5:9: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
    5 | typedef std::pair<ll , ll > pll;
      |         ^~~
hac.cpp: In function 'void up(int, int, int)':
hac.cpp:19:13: error: 'min' was not declared in this scope
   19 |    seg[l] = min(seg[l], x);
      |             ^~~
hac.cpp:24:13: error: 'min' was not declared in this scope
   24 |    seg[r] = min(seg[r], x);
      |             ^~~
hac.cpp: In function 'int get(int)':
hac.cpp:36:9: error: 'min' was not declared in this scope
   36 |   ans = min(ans, seg[i]);
      |         ^~~
hac.cpp: In function 'int main()':
hac.cpp:49:2: error: 'cin' was not declared in this scope
   49 |  cin.tie(0) -> sync_with_stdio(false);
      |  ^~~
hac.cpp:1:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
  +++ |+#include <iostream>
    1 | #define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
hac.cpp:50:2: error: 'fill' was not declared in this scope; did you mean 'll'?
   50 |  fill(seg, seg+2*N, inf);
      |  ^~~~
      |  ll
hac.cpp:69:9: error: 'max' was not declared in this scope
   69 |   ans = max(ans, get(i));
      |         ^~~
hac.cpp:70:2: error: 'cout' was not declared in this scope
   70 |  cout << ans << '\n';
      |  ^~~~
hac.cpp:70:2: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?