Submission #1308941

#TimeUsernameProblemLanguageResultExecution timeMemory
1308941lyra_g13Feast (NOI19_feast)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using ll = long long; using namespace std; int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); ll n, s; cin >> n >> s; vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } ll pos = 0; ll sum = 0; ll neg = 0; ll zero = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; if (a[i] > 0) pos++; if (a[i] == 0) { zero++; } if (a[i] < 0) { neg++; } } if (pos + zero == n) { cout << sum << "\n"; } else { if (neg == 1 and s == 1) { ll maxsub = 0; ll count = 0; for (int i = 0; i < n; i++) { if (a[i] >= 0) { count += a[i]; } else { maxsub = max(count, maxsub); count = 0; } } cout << maxsub << "\n"; } else { sum = 0; for (int i = 0; i < n; i++) { if (a[i] >= 0) { sum += a[i]; } } cout << sum << "\n"; } }

Compilation message (stderr)

feast.cpp: In function 'int main()':
feast.cpp:58:4: error: expected '}' at end of input
   58 |   }
      |    ^
feast.cpp:5:12: note: to match this '{'
    5 | int main() {
      |            ^