답안 #991306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
991306 2024-06-01T21:08:22 Z vjudge1 Feast (NOI19_feast) C++17
18 / 100
1000 ms 10064 KB
#include<bits/stdc++.h>
#include<ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define Fast ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define int long long
template<class T> using ordered_set = tree<T, null_type , less<T> ,rb_tree_tag , tree_order_statistics_node_update> ;
typedef long long ll;
const int N=3e5+3,LG=__lg(N)+2,M=21,MOD=998244353,inf=1e15;
int dp[2][N];
void solve() {
    int n,k;
    cin>>n>>k;
    vector<int>v(n+2);
    for (int i = 2; i <=n+1 ; ++i) {
        cin>>v[i];
        v[i]+=v[i-1];
    }
    for (int i = 1; i <=k ; ++i) {
        int best=0;
        for (int r = 2; r<=n+1 ; ++r) {
            dp[i&1][r]=(best=max(best,dp[(i-1)&1][r-2]-v[r-1]))+v[r];
        }
    }
    cout<<*max_element(dp[k&1],dp[k&1]+N)<<'\n';

}
signed main() {
    Fast;
    int tc = 1;
    //cin >> tc;
    for (int i = 1; i <= tc; ++i) {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1006 ms 10064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 6228 KB Output is correct
2 Correct 14 ms 6264 KB Output is correct
3 Correct 13 ms 6076 KB Output is correct
4 Execution timed out 1070 ms 8540 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 8020 KB Output is correct
2 Correct 24 ms 8020 KB Output is correct
3 Correct 23 ms 8020 KB Output is correct
4 Correct 23 ms 8128 KB Output is correct
5 Correct 23 ms 8020 KB Output is correct
6 Correct 23 ms 8284 KB Output is correct
7 Correct 23 ms 8284 KB Output is correct
8 Correct 29 ms 8016 KB Output is correct
9 Correct 30 ms 8276 KB Output is correct
10 Correct 24 ms 8276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1006 ms 10064 KB Time limit exceeded
2 Halted 0 ms 0 KB -