답안 #947157

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
947157 2024-03-15T15:16:00 Z NextBasilisk Cloud Computing (CEOI18_clo) C++14
0 / 100
25 ms 608 KB
#include <bits/stdc++.h>
#include <iostream>

#define ll long long
#define pb push_back
#define F first
#define S second

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll n;
    cin >> n;

    vector<pair<pair<ll,ll>, pair<ll,ll> > > action;

    for(ll i = 0; i < n; i++){
        ll c, f, v;
        cin >> c >> f >> v;
        action.pb({{f, 1}, {v, c}});
    }

    ll m;
    cin >> m;

    for(ll i = 0; i < m; i++){
        ll c, f, v;
        cin >> c >> f >> v;
        action.pb({{f, 0}, {v, c}});
    }

    sort(action.begin(), action.end());

    vector<ll> ans(50 * n + 100, -1e9); ans[0] = 0;

    while(!action.empty()){
        ll curC = action[action.size() - 1].S.S;
        ll curV = action[action.size() - 1].S.F;
        ll curT = action[action.size() - 1].F.S;

        if(curT == 1){
            for(ll i = 50 * n - curC; i >= 0; i--){
                if(ans[i + curC] > ans[i] - curV){
                    ans[i + curC] = ans[i] - curV;
                }
            }
        }
        else{
            for(ll i = curC; i <= 50 * n; i++){
                if(ans[i - curC] > ans[i] + curV){
                    ans[i - curC] = ans[i] + curV;
                }
            }
        }
        action.pop_back();
    }

    ll ansG = 0;

    for(int i = 0; i < ans.size(); i++){
        ansG = max(ansG, ans[i]);
    }

    cout << ansG << endl;
}

Compilation message

clo.cpp: In function 'int main()':
clo.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(int i = 0; i < ans.size(); i++){
      |                    ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 25 ms 608 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -