제출 #713548

#제출 시각아이디문제언어결과실행 시간메모리
713548NNerverCloud Computing (CEOI18_clo)C++14
18 / 100
438 ms1300 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; const long long LINF = 0x3f3f3f3f3f3f3f3f; const int MOD = 1e9+7; long long dp[MAXN]; bool mark[MAXN]; int N,M; vector<pair<int,pair<int,int> > > vec; void update(int id,long long x){ if(!mark[id]){ mark[id]=1; dp[id]=x; return; } dp[id]=max(dp[id],x); } int main(){ // freopen("guard.in", "r", stdin); // freopen("guard.out", "w", stdout); scanf("%d",&N); for(int i=1;i<=N;i++){ int c,f,v; scanf("%d%d%d",&c,&f,&v); vec.push_back({-f,{c,-v}}); } scanf("%d",&M); for(int i=1;i<=M;i++){ int c,f,v; scanf("%d%d%d",&c,&f,&v); vec.push_back({-f,{c,v}}); } sort(vec.begin(),vec.end()); memset(mark,0,sizeof(mark)); mark[0]=1; dp[0]=0; for(int i=1;i<=N+M;i++){ int f=-vec[i-1].first; int c=vec[i-1].second.first; int v=vec[i-1].second.second; if(v>0){ for(int j=0;j+c<=N*50;j++){ if(mark[j+c]) update(j,dp[j+c]+v); } } else{ for(int j=N*50-c;j>=0;j--){ if(mark[j]) update(j+c,dp[j]+v); } } } long long ans=0; for(int i=1;i<=N*50;i++) ans=max(ans,dp[i]); printf("%lld\n",ans); return 0; }

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

clo.cpp: In function 'int main()':
clo.cpp:40:13: warning: unused variable 'f' [-Wunused-variable]
   40 |         int f=-vec[i-1].first;
      |             ^
clo.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
clo.cpp:27:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         int c,f,v; scanf("%d%d%d",&c,&f,&v);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~
clo.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     scanf("%d",&M);
      |     ~~~~~^~~~~~~~~
clo.cpp:32:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         int c,f,v; scanf("%d%d%d",&c,&f,&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...