제출 #833130

#제출 시각아이디문제언어결과실행 시간메모리
833130veehjFeast (NOI19_feast)C++17
4 / 100
1071 ms5000 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define F first #define S second #define pb push_back #define sz(a) (int)a.size() #define all(x) (x).begin(), (x).end() int n, k; vector<ll> a; void f(){ vector<ll> p=a; for(int i=1; i<n; i++) p[i]+=p[i-1]; ll ans=0; for(int i=0; i<n; i++){ for(int j=0; j<i; j++){ ans=max(ans, p[i]-p[j]); } } cout << ans << endl; return; } int main(){ cin >> n >> k; for(int i=0; i<n; i++){ ll x; cin >> x; a.pb(x); } if(k==1) f(); else{ ll cnt=0; for(int i=0; i<n; i++) if(a[i]>0) cnt+=a[i]; cout << cnt << endl; } }
#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...