답안 #1094218

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094218 2024-09-29T03:16:13 Z Trisanu_Das Feast (NOI19_feast) C++17
30 / 100
27 ms 5724 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
signed main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, k; cin >> n >> k;
  int a[n]; for(int i = 0; i < n; i++) cin >> a[i];
  int ans = 0, curr = 0, sm = 0;
  for(int i = 0; i < n; i++){
    if(a[i] >= 0) sm += a[i];
    curr += a[i];
    ans = max(ans, curr);
    curr = max(curr, 0ll);
  }
  if(k == 1) cout << ans << '\n';
  else cout << sm << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 5468 KB Output is correct
2 Correct 22 ms 5576 KB Output is correct
3 Correct 21 ms 5464 KB Output is correct
4 Correct 21 ms 5580 KB Output is correct
5 Correct 21 ms 5440 KB Output is correct
6 Correct 20 ms 5396 KB Output is correct
7 Correct 27 ms 5264 KB Output is correct
8 Correct 26 ms 5460 KB Output is correct
9 Correct 20 ms 5464 KB Output is correct
10 Correct 20 ms 5464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 3680 KB Output is correct
2 Correct 13 ms 3932 KB Output is correct
3 Correct 14 ms 3680 KB Output is correct
4 Correct 13 ms 3768 KB Output is correct
5 Correct 20 ms 5396 KB Output is correct
6 Correct 13 ms 3744 KB Output is correct
7 Correct 13 ms 3808 KB Output is correct
8 Correct 22 ms 5456 KB Output is correct
9 Correct 20 ms 5464 KB Output is correct
10 Correct 13 ms 3676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 5564 KB Output is correct
2 Correct 25 ms 5668 KB Output is correct
3 Correct 24 ms 5568 KB Output is correct
4 Correct 23 ms 5712 KB Output is correct
5 Correct 23 ms 5724 KB Output is correct
6 Correct 23 ms 5712 KB Output is correct
7 Correct 23 ms 5712 KB Output is correct
8 Correct 23 ms 5712 KB Output is correct
9 Correct 27 ms 5724 KB Output is correct
10 Correct 25 ms 5712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 456 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 456 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 456 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 5468 KB Output is correct
2 Correct 22 ms 5576 KB Output is correct
3 Correct 21 ms 5464 KB Output is correct
4 Correct 21 ms 5580 KB Output is correct
5 Correct 21 ms 5440 KB Output is correct
6 Correct 20 ms 5396 KB Output is correct
7 Correct 27 ms 5264 KB Output is correct
8 Correct 26 ms 5460 KB Output is correct
9 Correct 20 ms 5464 KB Output is correct
10 Correct 20 ms 5464 KB Output is correct
11 Correct 13 ms 3680 KB Output is correct
12 Correct 13 ms 3932 KB Output is correct
13 Correct 14 ms 3680 KB Output is correct
14 Correct 13 ms 3768 KB Output is correct
15 Correct 20 ms 5396 KB Output is correct
16 Correct 13 ms 3744 KB Output is correct
17 Correct 13 ms 3808 KB Output is correct
18 Correct 22 ms 5456 KB Output is correct
19 Correct 20 ms 5464 KB Output is correct
20 Correct 13 ms 3676 KB Output is correct
21 Correct 24 ms 5564 KB Output is correct
22 Correct 25 ms 5668 KB Output is correct
23 Correct 24 ms 5568 KB Output is correct
24 Correct 23 ms 5712 KB Output is correct
25 Correct 23 ms 5724 KB Output is correct
26 Correct 23 ms 5712 KB Output is correct
27 Correct 23 ms 5712 KB Output is correct
28 Correct 23 ms 5712 KB Output is correct
29 Correct 27 ms 5724 KB Output is correct
30 Correct 25 ms 5712 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Incorrect 0 ms 456 KB Output isn't correct
34 Halted 0 ms 0 KB -