제출 #431324

#제출 시각아이디문제언어결과실행 시간메모리
431324A_D카니발 티켓 (IOI20_tickets)C++14
27 / 100
736 ms126752 KiB
#include "tickets.h" #include <bits/stdc++.h> #define ll long long #define ii pair<ll,ll> #define F first #define S second using namespace std; const int NN=1520; ii a[NN]; ii b[NN]; pair<long long,ii> dp[NN][NN]; long long ans=0; long long find_maximum(int k,vector<vector<int>>x){ int n=x.size(); int m=x[0].size(); // cout<<endl; for(int j=0;j<n;j++){ a[j]={1e9,1e9}; b[j]={0,0}; for(int i=0;i<m;i++){ a[j]=min(a[j],{x[j][i],i}); b[j]=max(b[j],{x[j][i],i}); } // cout<<a[j].F<<" "<<b[j].F<<endl; } //cout<<endl; for(int i=0;i<=n;i++){ for(int j=0;j<=n;j++){ dp[i][j].first=-1e18; } } vector<vector<int>> ann; vector<int> vec; for(int i=0;i<x[0].size();i++){ vec.push_back(-1); } for(int i=0;i<x.size();i++)ann.push_back(vec); vec.clear(); dp[0][0]={-a[0].F,{0,a[0].S}}; dp[0][1]={+b[0].F,{0,b[0].S}}; for(int i=0;i<n-1;i++){ for(int j=0;j<n-1;j++){ dp[i+1][j]=max(dp[i+1][j],{dp[i][j].F-a[i+1].F,{j,a[i+1].S}}); dp[i+1][j+1]=max(dp[i+1][j+1],{dp[i][j].F+b[i+1].F,{j,b[i+1].S}}); } } /* cout<<endl; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ cout<<dp[i][j].F<<" "; } cout<<endl; } cout<<endl; */ ans=dp[n-1][n/2].F; int idx=n-1,me=n/2; while(idx>=0){ ann[idx][dp[idx][me].S.S]=0; me=dp[idx][me].S.F; idx--; } allocate_tickets(ann); return ans; }

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

tickets.cpp: In function 'long long int find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for(int i=0;i<x[0].size();i++){
      |                 ~^~~~~~~~~~~~
tickets.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i=0;i<x.size();i++)ann.push_back(vec);
      |                 ~^~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...