제출 #762115

#제출 시각아이디문제언어결과실행 시간메모리
762115Doncho_BonbonchoCloud Computing (CEOI18_clo)C++14
100 / 100
1632 ms3640 KiB
#include <bits/stdc++.h> using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #define endl "\n" template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; } template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; } #ifndef LOCAL #define cerr if(false) cerr #define endl "\n" #endif template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) { return os << "(" << p.first << ", " << p.second << ")"; } template<typename T, typename B = decay<decltype(*begin(declval<T>()))>, typename enable_if<!is_same<T, string>::value>::type* = nullptr> ostream& operator <<(ostream &os, const T &c) { bool f = false; os << "("; for(const auto &x : c) { if(f) os << ", "; f = true; os << x; } return os << ")"; } #define out(x) #x << "=" << x << " " struct debug { debug(const string &msg) { cerr << "LINE " << msg << ": "; } ~debug() { cerr << endl; } template<class T> debug& operator <<(const T x) { cerr << x; return *this; } }; #define dbg debug(to_string(__LINE__)) typedef long long ll; const ll mod = 1e9 + 7; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// struct Har{ int core; int rate; int money; }; std::vector< Har > all; signed main() { #ifndef LOCAL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #endif int n; std::cin>>n; int maxC = 0; for( int i=0 ; i<n ; i++ ){ Har curr; std::cin>>curr.core>>curr.rate>>curr.money; curr.money *= -1; maxC += curr.core; all.push_back( curr ); } int m; std::cin>>m; for( int i=0 ; i<m ; i++ ){ Har curr; std::cin>>curr.core>>curr.rate>>curr.money; maxC += curr.core; curr.core *= -1; all.push_back( curr ); } std::sort( all.begin(), all.end(), []( const Har& a, const Har& b){ return a.rate != b.rate ? a.rate > b.rate : a.money < b.money; }); std::vector< ll > dpPrev( maxC + 42, INT64_MIN ); dpPrev[0] = 0; for( int i=0 ; i<all.size() ; i++ ){ std::vector< ll > dpNow( dpPrev ); for( int j=0 ; j<=maxC ; j++ ){ int currC = j - all[i].core; cerr<<out( currC )<<endl; if( currC < 0 || currC > maxC || dpPrev[currC] == INT64_MIN ) continue; cerr<<out( dpPrev[currC] ) <<endl; chkmax( dpNow[j], dpPrev[currC] + all[i].money ); cerr<<out(i)<<" "<<out(j)<<" "<<out( dpNow[j] )<<endl; } dpPrev = dpNow; } cerr<<dpPrev<<endl; std::cout<< *max_element( dpPrev.begin(), dpPrev.end() )<<endl; return 0; } // To the OGs, I'm thankin' you now // Was watchin' you when you was pavin' the ground // I copied your cadence, I mirrored your style // I studied the greats, I'm the greatest right now

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

clo.cpp: In function 'std::ostream& operator<<(std::ostream&, const T&)':
clo.cpp:24:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   24 |         if(f) os << ", "; f = true;
      |         ^~
clo.cpp:24:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   24 |         if(f) os << ", "; f = true;
      |                           ^
clo.cpp: In function 'int main()':
clo.cpp:88:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Har>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |  for( int i=0 ; i<all.size() ; i++ ){
      |                 ~^~~~~~~~~~~
#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...