제출 #470268

#제출 시각아이디문제언어결과실행 시간메모리
470268nia_azmCloud Computing (CEOI18_clo)C++14
100 / 100
848 ms2060 KiB
#include<bits/stdc++.h>
using namespace std;
 
typedef pair<long long, long long> pll;
typedef pair<int, long long> pil;
typedef pair<long long, int> pli;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
 
#define mp make_pair
#define pb push_back
#define in insert
#define ers erase
#define S second
#define F first
 
const ll inF = 1e18 + 5;
const int N = 1e5 + 5;
int n, m;
ll ans, dp[5][N];
 
struct strct {
        int c, f, v;
};
vector<strct> vec;
 
int cmp(strct i, strct j){
        if (i.f == j.f){
                if (i.c > j.c) return 1;
                return 0;
        }
        if (i.f > j.f) return 1;
        return 0;
}
 
void read_input() {
        cin >> n;
        for (int i = 0; i < n; i++) {
                int cc, ff, v;
                cin >> cc >> ff >> v;
                v *= -1;
                strct x;
                x.c = cc, x.f = ff, x.v = v;
                vec.pb(x);
        }
        cin >> m;
        for (int i = 0; i < m; i++) {
                int cc, ff, v;
                cin >> cc >> ff >> v;
                cc *= (-1);
                strct x;
                x.c = cc; x.f = ff; x.v = v;
                vec.pb(x);
        }
        sort(vec.begin(), vec.end(), cmp);
}
 
void solve() {
        for (int i = 1; i < N; i++) dp[0][i]= -inF;
        for (int i = 0; i < vec.size(); i++) {
                for (int j = 0; j < N; j++) {
                        if (j < vec[i].c) dp[1][j] = dp[0][j];
                        else if (j - vec[i].c >= N) dp[1][j] = dp[0][j];
                        else dp[1][j] = max(dp[0][j - vec[i].c] + vec[i].v, dp[0][j]);
                }
                for (int j = 0; j < N; j++) dp[0][j] = dp[1][j];
        }
        for (int j = 0; j < N; j++) ans = max(ans, dp[0][j]);
        cout << ans << '\n';
}
 
int main() {
        ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
        read_input(), solve();
        return 0;
}

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

clo.cpp: In function 'void solve()':
clo.cpp:61:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<strct>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for (int i = 0; i < vec.size(); 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...