제출 #1034408

#제출 시각아이디문제언어결과실행 시간메모리
1034408vjudge1Cloud Computing (CEOI18_clo)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; struct thing{ int core,clock,price,type; }; bool cmp(thing q,thing w ){ if(q.clock!=w.clock){ return q.clock<w.clock; } else{ return q.type>w.type; } } int main(){ int n; cin>>n; thing barang[n+m+2]; vector<thing>tmp; int sum=0; for(int q=1;q<=n;q++){ cin>>barang[q-1].core>>barang[q-1].clock>>barang[q-1].price; barang[q-1].type=0; tmp.push_back(barang[q-1]); sum+=barang[q-1].price; } int m; cin>>m; for(int q=1;q<=m;q++){ cin>>barang[n+q-1].core>>barang[n+q-1].clock>>barang[n+q-1].price; barang[n+q-1].type=1; tmp.push_back(barang[n+q-1]); } sort(tmp.begin(),tmp.end(),cmp); long long dp[sum+2]; for(int w=0;w<=sum;w++){ dp[w]=-1e15; } dp[0]=0; for(int q=n+m;q>=1;q--){ auto [a,b,c,tipe]=tmp[q-1]; if(tipe==0){ for(int w=sum;w>=a;w--){ dp[w]=max(dp[w],dp[w-a]-c); } } else{ for(int w=0;w+a<=sum;w++){ dp[w]=max(dp[w],dp[w+a]+c); } } } long long ans=0; for(int q=0;q<=sum;q++){ ans=max(ans,dp[q]); } cout<<ans<<endl; }

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

clo.cpp: In function 'int main()':
clo.cpp:20:20: error: 'm' was not declared in this scope
   20 |     thing barang[n+m+2];
      |                    ^
clo.cpp:24:14: error: 'barang' was not declared in this scope
   24 |         cin>>barang[q-1].core>>barang[q-1].clock>>barang[q-1].price;
      |              ^~~~~~
clo.cpp:32:14: error: 'barang' was not declared in this scope
   32 |         cin>>barang[n+q-1].core>>barang[n+q-1].clock>>barang[n+q-1].price;
      |              ^~~~~~