# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1083839 | lamlamlam | Feast (NOI19_feast) | C++17 | 22 ms | 5772 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
struct node
{
int pre_max,pre_min,suf_max,suf_min,best,worst;
};
node rev(node x)
{
x.pre_max *= -1;
x.pre_min *= -1;
x.suf_max *= -1;
x.suf_min *= -1;
x.best *= -1;
x.worst *= -1;
swap(x.pre_max,x.pre_min);
swap(x.suf_max,x.suf_min);
swap(x.best,x.worst);
return x;
}
const int MN = 3e5+5,inf = 1e18;
int n,k,a[MN],pre[MN];
void sub34()
{
int l,r,cur_max,res = 0;
while(k--){
for(int i=1; i<=n; i++) pre[i] = a[i] + pre[i-1];
cur_max = 0;
for(int i=1; i<=n; i++){
for(int j=i; j<=n; j++){
if(pre[j]-pre[i-1] > cur_max){
cur_max = pre[j] - pre[i-1];
l = i;
r = j;
}
}
}
if(cur_max==0) break;
for(int i=l; i<=r; i++) res += a[i],a[i] = -a[i];
}
cout << res;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#define task "sus"
if(fopen(task".inp","r")){
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
cin >> n >> k;
for(int i=1; i<=n; i++) cin >> a[i];
if(n<=300) return sub34(),0;
cerr << "\nTime: " << clock();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |