답안 #160768

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
160768 2019-10-29T21:24:44 Z Rouge_Hugo Cloud Computing (CEOI18_clo) C++14
0 / 100
25 ms 376 KB
#include <bits/stdc++.h>
using namespace std;
int n,m;
vector<pair<long long,pair<long long ,long long >>>v;
const long long M=50*2001;
long long d[2][M+100],vis[2][M+100];
const long long inf=1e15;
void solve()
{
    long long last=0,l=0;
    d[0][0]=0;
    if (v[0].second.first>0){d[0][v[0].second.first]=v[0].second.second;vis[0][v[0].second.first]=1;}
    for(long long i=1;i<n;i++)
    {
        for(long long  j=0;j<M-1;j++)
        {
            if (vis[(i+1)%2][j]){d[i%2][j]=max(d[(i+1)%2][j],(long long )0);vis[i%2][j]=1;}
            if (j-v[i].second.first>0&&vis[(i+1)%2][j-v[i].second.first]==1)
                {d[i%2][j]=max(d[i%2][j],d[(i+1)%2][j-v[i].second.first]+v[i].second.second);
                vis[i%2][j]=1;
                }

            last=max(d[i%2][j],last);
        }
    }
    cout<< max(last,(long long)0) ;
}
int main()
{
    cin>>n;
    long long x,y,z;
    for(long long i=0;i<n;i++)
    {
        cin>>x>>y>>z;
        v.push_back({y,{x,-z}});
    }
    cin>>m;
    for(long long i=0;i<m;i++)
    {
        cin>>x>>y>>z;
        v.push_back({y,{-x,+z}});
    }
    n+=m;
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    solve();
}

Compilation message

clo.cpp: In function 'void solve()':
clo.cpp:10:22: warning: unused variable 'l' [-Wunused-variable]
     long long last=0,l=0;
                      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Incorrect 25 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Incorrect 25 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -