Submission #966843

# Submission time Handle Problem Language Result Execution time Memory
966843 2024-04-20T13:15:48 Z jadai007 Feast (NOI19_feast) C++14
0 / 100
1000 ms 2900 KB
#include<bits/stdc++.h>

using namespace std;

int n,k, arr[300300], l, r, vis[300300], mx, sum, now, ans;

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n >> k;
    for(int i = 1; i<=n; ++i) cin >> arr[i];
    for(int i = 1; i<=k; ++i){
        mx = -1e9 - 7;
        int cnt = 0, now = 0, sum = 0;
        for(int j = 1; j<=n; ++j){
            //cout << vis[j] << ' ';
            if(vis[j]){
                sum = 0;
                continue;
            }
            sum+=arr[j];
            cnt++;
            if(sum < 0){
                sum = 0;
                cnt = 0;
            }
            if(mx < sum){
                mx = sum;
                now = cnt;
                r = j;
            }
        }
        for(int j = r - now + 1; j<=r; ++j) vis[j] = 1;
        ans+=mx;
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 2900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 2652 KB Output is correct
2 Correct 15 ms 2652 KB Output is correct
3 Correct 15 ms 2652 KB Output is correct
4 Execution timed out 1094 ms 2652 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 2900 KB Time limit exceeded
2 Halted 0 ms 0 KB -