Submission #374123

#TimeUsernameProblemLanguageResultExecution timeMemory
374123mariowongBigger segments (IZhO19_segments)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define int long long #define push_back emplace_back #define push_front emplace_front #define pii pair<int,int> #define ff first #define ss second using namespace std; #define debug(args...) kout("[ " + string(#args) + " ]", args) void kout() { cerr << endl; } template <class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ',kout(b...); } template <class T> void pary(T L, T R) { while (L != R) cerr << *L << " \n"[++L==R]; } const int MAXN = 500000; int n; int a[MAXN+1]; int pre[MAXN+1]; int dp[MAXN+1]; int len[MAXN+1]; deque <pii> deq; signed main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i], pre[i] = pre[i-1] + a[i]; deq.push_back(0, 0); pii tmp; for (int i = 1; i <= n; i++) { while (deq.size() && pre[i]-pre[deq.front().ss] >= deq.front().ff) { dp[i] = dp[deq.front().ss] + 1; tmp = deq.front(); deq.pop_front(); } deq.push_front(tmp); while (deq.size() && deq.back().ff >= pre[i]-pre[deq.front().ss]) deq.pop_back(); deq.push_back(pre[i]-pre[deq.front().ss], i); } cout << dp[n] << '\n';

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:40:24: error: expected '}' at end of input
   40 |   cout << dp[n] << '\n';
      |                        ^
segments.cpp:22:15: note: to match this '{'
   22 | signed main() {
      |               ^