제출 #443211

#제출 시각아이디문제언어결과실행 시간메모리
443211LittleCubeCloud Computing (CEOI18_clo)C++14
0 / 100
3 ms1996 KiB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
using namespace std;

ll M, N, com[100005], order[100005], f;
vector<pll> vn, vm;

signed int main()
{
    cin >> N;
    vn.resize(N + 1);
    for (int i = 1; i <= N; i++)
        cin >> vn[i].F >> f >> vn[i].S;

    cin >> M;
    vm.resize(M + 1);
    for (int i = 1; i <= M; i++)
        cin >>  vm[i].F >> f >> vm[i].S;

    for (int i = 1; i <= 1000000; i++)
        com[i] = 1e18;

    for (int i = 1; i <= N; i++)
        for (int j = N * 50; j >= vn[i].F; j++)
            com[i] = min(com[i], com[i - vn[i].F] + vn[i].S);
    
    for (int i = 1; i <= M; i++)
        for (int j = M * 50; j >= vm[i].F; j++)
            order[i] = max(order[i], order[i - vm[i].F] + vm[i].S);

    for (int i = N * 50 - 1; i >= 0; i++)
        com[i] = min(com[i], com[i + 1]);

    ll ans = 0;


    for (int i = 0; i <= M * 50; i++)
        ans = max(ans, order[i] - com[i]);

    cout << ans << '\n';
}

컴파일 시 표준 에러 (stderr) 메시지

clo.cpp: In function 'int main()':
clo.cpp:25:16: warning: iteration 100004 invokes undefined behavior [-Waggressive-loop-optimizations]
   25 |         com[i] = 1e18;
      |         ~~~~~~~^~~~~~
clo.cpp:24:23: note: within this loop
   24 |     for (int i = 1; i <= 1000000; i++)
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...