제출 #163001

#제출 시각아이디문제언어결과실행 시간메모리
163001AkashiCloud Computing (CEOI18_clo)C++14
100 / 100
816 ms2116 KiB
#include <bits/stdc++.h>
using namespace std;

struct usu{
    int c, f, v, t;
    bool operator < (const usu &aux)const{
        if(f != aux.f) return f < aux.f;
        return t > aux.t;
    }
};

usu a[4005];

int n, nr;
long long d[2][100005];

int main()
{
//    freopen("1.in", "r", stdin);

    scanf("%d", &n);
    for(int i = 1; i <= n ; ++i){
        ++nr;
        scanf("%d%d%d", &a[nr].c, &a[nr].f, &a[nr].v);
        a[nr].t = 0;
    }

    scanf("%d", &n);
    for(int i = 1; i <= n ; ++i){
        ++nr;
        scanf("%d%d%d", &a[nr].c, &a[nr].f, &a[nr].v);
        a[nr].t = 1;
    }

    sort(a + 1, a + nr + 1);

    int l = 0;
    memset(d[1], -0x3f, sizeof(d[1]));
    d[1][0] = 0;
    for(int i = 1; i <= nr ; ++i, l = 1 - l){

        for(int j = 0; j <= 100000 ; ++j) d[l][j] = d[1 - l][j];

        if(a[i].t == 0){
            for(int j = 1; j < a[i].c ; ++j)
                d[l][0] = max(d[l][0], d[1 - l][j] - a[i].v);

            for(int j = 0; j + a[i].c <= 100000 ; ++j)
                d[l][j] = max(d[l][j], d[1 - l][j + a[i].c] - a[i].v);
        }
        else{
            for(int j = a[i].c; j <= 100000 ; ++j)
                d[l][j] = max(d[l][j], d[1 - l][j - a[i].c] + a[i].v);
        }
    }

    l = 1 - l;
    printf("%lld", d[l][0]);

    return 0;
}




















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

clo.cpp: In function 'int main()':
clo.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
clo.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &a[nr].c, &a[nr].f, &a[nr].v);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
clo.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &a[nr].c, &a[nr].f, &a[nr].v);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...