답안 #269923

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
269923 2020-08-17T11:17:57 Z kaplanbar Go (COCI18_go) C++14
20 / 100
1 ms 512 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Pk {
    ll a, b, t;
    bool operator<(const Pk other) const {
        return a < other.a;
    }
};
ll n, k, m, sz1, sz2;;
Pk v1[105],v2[105];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k >> m;
    for(int i = 0; i < m; i++) {
        int a, b, t;
        cin >> a >> b >> t;
        if(a>k) v1[sz1++]={a,b,t};
        else v2[sz2++]={a,b,t};
    }
    sort(v1, v1+sz1);
    
    sort(v2, v2+sz2);
    reverse(v2, v2+sz2);

    ll ans = 0;

    ll s = 0;

    for(int i = 0; i < sz1; i++) {
        if(v1[i].t > v1[i].a - k) s += v1[i].b;

        int tim = (v1[i].a - k) * 2;

        ll s2 = 0;

        for(int j = 0; j < sz2; j++) {
            assert(v2[i].a < k);
            if(v2[j].t > k - v2[i].a  + tim) s2 += v2[j].b;
        }

        ans = max(ans, s + s2);
    }

    s = 0;

    for(int i = 0; i < sz2; i++) {
        if(v2[i].t > k - v2[i].a) s += v2[i].b;

        int tim = (k - v2[i].a) * 2;

        ll s2 = 0;

        for(int j = 0; j < sz1; j++) {
            assert(v1[i].a > k);
            if(v1[j].t > v1[i].a - k + tim) s2 += v1[j].b;
        }

        ans = max(ans, s + s2);
    }

    cout << ans;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11
3 Correct 0 ms 384 KB Output is correct
4 Incorrect 0 ms 384 KB Output isn't correct
5 Runtime error 1 ms 512 KB Execution killed with signal 11
6 Incorrect 1 ms 384 KB Output isn't correct
7 Runtime error 1 ms 512 KB Execution killed with signal 11
8 Incorrect 0 ms 384 KB Output isn't correct
9 Incorrect 0 ms 384 KB Output isn't correct
10 Runtime error 1 ms 512 KB Execution killed with signal 11