답안 #935812

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
935812 2024-02-29T14:42:00 Z imarn Feast (NOI19_feast) C++14
59 / 100
70 ms 13936 KB
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define vp vector<pii>
using namespace std;
const int N=3e5+5;
ll a[N]{0};
pll dp[N];
pll mx[N];
pll solve(ll x,int n){
    dp[0]=mx[0]={0,0};
    for(int i=1;i<=n;i++){
        dp[i] = max(dp[i-1],{mx[i-1].f+a[i]-x,mx[i-1].s+1});
        mx[i] = max(mx[i-1],{dp[i].f-a[i],dp[i].s});
    }return dp[n];
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,k;cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i],a[i]+=a[i-1];
    ll l=0,r=1e12;
    while(l<r){
        ll m=(l+r)>>1;
        if(solve(m,n).s<=k)r=m;
        else l=m+1;
    }cout<<solve(l,n).f+l*k;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 13392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 12888 KB Output is correct
2 Correct 52 ms 13144 KB Output is correct
3 Correct 47 ms 13140 KB Output is correct
4 Incorrect 50 ms 13140 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 13904 KB Output is correct
2 Correct 68 ms 13904 KB Output is correct
3 Correct 67 ms 13900 KB Output is correct
4 Correct 68 ms 13724 KB Output is correct
5 Correct 68 ms 13936 KB Output is correct
6 Correct 68 ms 13912 KB Output is correct
7 Correct 67 ms 13848 KB Output is correct
8 Correct 67 ms 13744 KB Output is correct
9 Correct 70 ms 13916 KB Output is correct
10 Correct 69 ms 13904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4560 KB Output is correct
5 Correct 1 ms 4640 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4560 KB Output is correct
5 Correct 1 ms 4640 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4632 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4560 KB Output is correct
5 Correct 1 ms 4640 KB Output is correct
6 Correct 1 ms 4696 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4632 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4456 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4444 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4588 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4588 KB Output is correct
29 Correct 1 ms 4444 KB Output is correct
30 Correct 1 ms 4456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 13392 KB Output isn't correct
2 Halted 0 ms 0 KB -