제출 #870269

#제출 시각아이디문제언어결과실행 시간메모리
870269rsjwCloud Computing (CEOI18_clo)C++17
100 / 100
566 ms2388 KiB
#include <bits/stdc++.h> using namespace std; #define int long long tuple<int,int,int> a[4010]; int v[4010],w[4010]; int f[2][100010]; void chmax(int &x,int y) { x=max(x,y); } signed main() { int n,m,i,j,k,p,u; cin>>n; int l=0; for(i=1; i<=n; i++) cin>>j>>u>>k,a[++l]=make_tuple(-2*u,j,-k); cin>>m; for(i=1; i<=m; i++) cin>>j>>u>>k,a[++l]=make_tuple(-2*u+1,-j,k); sort(a+1,a+l+1); n=l; for(i=1; i<=n; i++) { tie(j,k,u)=a[i]; v[i]=k,w[i]=u; } memset(f,0xaf,sizeof(f)); f[0][0]=0; for(i=0; i<n; i++) { memset(f[i&1^1],0xaf,sizeof(f[i&1^1])); for(j=0; j<=100002; j++) { if(j+v[i+1]>=0) chmax(f[i&1^1][j+v[i+1]],f[i&1][j]+w[i+1]); chmax(f[i&1^1][j],f[i&1][j]); } } int ans=0; for(j=0; j<=100002; j++) ans=max(ans,f[n&1][j]); cout<<ans<<endl; return 0; }

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

clo.cpp: In function 'int main()':
clo.cpp:25:13: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   25 |   memset(f[i&1^1],0xaf,sizeof(f[i&1^1]));
      |            ~^~
clo.cpp:25:34: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   25 |   memset(f[i&1^1],0xaf,sizeof(f[i&1^1]));
      |                                 ~^~
clo.cpp:27:29: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   27 |    if(j+v[i+1]>=0) chmax(f[i&1^1][j+v[i+1]],f[i&1][j]+w[i+1]);
      |                            ~^~
clo.cpp:28:13: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   28 |    chmax(f[i&1^1][j],f[i&1][j]);
      |            ~^~
clo.cpp:11:16: warning: unused variable 'p' [-Wunused-variable]
   11 |  int n,m,i,j,k,p,u;
      |                ^
#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...