답안 #950550

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
950550 2024-03-20T12:22:24 Z VMaksimoski008 Feast (NOI19_feast) C++14
4 / 100
91 ms 1620 KB
#include <bits/stdc++.h>

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
const double eps = 1e-9;

int32_t main() {
    int n, k, neg = 0;
    cin >> n >> k;

    vector<int> v(n+1);
    for(int i=1; i<=n; i++) cin >> v[i], neg += (v[i] < 0);

    if(neg == 0) {
        ll ans = 0;
        for(int &x : v) ans += x;
        cout << ans << '\n';
        return 0;
    }

    if(neg == 1) {
        ll ans = 0, el = 0;
        for(int &x : v) {
            ans += x;
            if(x < 0) el = x;
        }

        if(n == k) cout << ans << '\n';
        else cout << ans - el << '\n';
        return 0;
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 1368 KB Output is correct
2 Correct 79 ms 1368 KB Output is correct
3 Correct 84 ms 1592 KB Output is correct
4 Correct 80 ms 1372 KB Output is correct
5 Correct 91 ms 1368 KB Output is correct
6 Correct 79 ms 1620 KB Output is correct
7 Correct 86 ms 1572 KB Output is correct
8 Correct 80 ms 1580 KB Output is correct
9 Correct 78 ms 1372 KB Output is correct
10 Correct 81 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 1368 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 91 ms 1372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 1368 KB Output is correct
2 Correct 79 ms 1368 KB Output is correct
3 Correct 84 ms 1592 KB Output is correct
4 Correct 80 ms 1372 KB Output is correct
5 Correct 91 ms 1368 KB Output is correct
6 Correct 79 ms 1620 KB Output is correct
7 Correct 86 ms 1572 KB Output is correct
8 Correct 80 ms 1580 KB Output is correct
9 Correct 78 ms 1372 KB Output is correct
10 Correct 81 ms 1372 KB Output is correct
11 Incorrect 42 ms 1368 KB Output isn't correct
12 Halted 0 ms 0 KB -