제출 #917291

#제출 시각아이디문제언어결과실행 시간메모리
917291406Feast (NOI19_feast)C++17
18 / 100
48 ms9424 KiB
#include <bits/stdc++.h> #define int int64_t #define FOR(i, a, b) for (int i = (a); i < (b); ++i) using namespace std; using ar = array<int, 2>; const int64_t INF = 1ll << 60; const int N = 3e5 + 5; int n, k; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> k; vector<int> v; int s = 0; FOR(i, 0, n) { int a; cin >> a; s += a; if (s < 0) s = 0; v.push_back(s); } sort(v.rbegin(), v.rend()); cout << accumulate(v.begin(), v.begin() + k, 0ll); return 0; }
#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...