제출 #1319762

#제출 시각아이디문제언어결과실행 시간메모리
1319762vaishakhvFeast (NOI19_feast)C++20
4 / 100
27 ms7380 KiB
// Source: https://usaco.guide/general/io #include <bits/stdc++.h> using namespace std; using ll = long long; #define eb emplace_back // faster than push_back xD // pbds UwU #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; #define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> // use pair for ms // my io library :D #define m1(x) template<class T, class... U> void x(T&& a, U&&... b) #define m2(x) (ll[]){(x forward<U>(b),0)...} m1(pr){cout << forward<T>(a); m2(cout << " " <<); cout << "\n";} m1(re){cin >> forward<T>(a); m2(cin >>);} int main() { ios::sync_with_stdio(0); cin.tie(0); ll n, k; re(n, k); vector<ll> a(n); for (ll i{}; i < n; i++) re(a[i]); ll sum = accumulate(a.begin(), a.end(), 0LL); vector<ll> prefsum(n+1, 0), suffsum(n+1, 0); for (ll i{}; i < n; i++){ prefsum[i+1] = prefsum[i] + a[i]; } for (ll i=n-1; i >= 0; i--){ suffsum[i] = suffsum[i+1] + a[i]; } bool ok = true; for (ll i{}; i < n; i++){ if (a[i] < 0 && ok){ pr(prefsum[i] + suffsum[i+1]); ok = false; } } if(ok) pr(sum); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...