Submission #1325905

#TimeUsernameProblemLanguageResultExecution timeMemory
1325905sh_qaxxorov_571Bigger segments (IZhO19_segments)C++20
Compilation error
0 ms0 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL)
    int n;
    cin >> n;
    vector<ll> a(n + 1);
    vector<ll> pref(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pref[i] = pref[i - 1] + a[i];
    }
    vector<int> dp(n + 2, 0);
    vector<ll> s(n + 2, 0);
    int j = n;
    for (int i = n; i >= 1; i--) {
        while (pref[j] - pref[i - 1] < s[j + 1]) {
            j--;
        }
        dp[i] = dp[j + 1] + 1;
        s[i] = pref[j] - pref[i - 1];
     }

    cout << dp[1] << endl;

    return 0;
}

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:8:18: error: expected ';' before 'int'
    8 |     cin.tie(NULL)
      |                  ^
      |                  ;
    9 |     int n;
      |     ~~~           
segments.cpp:10:12: error: 'n' was not declared in this scope
   10 |     cin >> n;
      |            ^