제출 #764832

#제출 시각아이디문제언어결과실행 시간메모리
764832abhinavshukla408Cloud Computing (CEOI18_clo)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <set> #include <string> #include <unordered_set> #include <unordered_map> #include <map> #include <stack> #include <queue> #include <algorithm> #include <cassert> #include <math.h> using namespace std; #define endl "\n" #define int int64_t #define pb push_back #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define FOR0(i,a) FOR(i,0,a) #define FOR1(i,a) for (int i = (1); i <= (a); ++i) #define TRAV(a,x) for (auto& a: x) using pii = pair<int,int>; using vi = vector<int>; struct transaction{ int cores; int frames; int profit; }; bool cmp(transaction a, transaction b){ if(a.frames!=b.frames){ return a.frames>b.frames; }else{ return a.profit<b.profit; } } int32_t main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin>>N; int cores=0; vector<transaction> transactions; FOR0(i,N){ int a,b,c; cin>>a>>b>>c; cores+=a; transactions.pb({a,b,-c}); } int M; cin>>M; FOR0(i,M){ int a,b,c; cin>>a>>b>>c; transactions.pb({-a,b,c}); } sort(transactions.begin(),transactions.end(),cmp); // TRAV(i,transactions){ // cout<<i.cores<<" "<<i.frames<<" "<<i.profit<<endl; // } int dp[transactions.size()+2][cores+2]; FOR0(i,transactions.size()+1){ FOR0(j,cores+1){ dp[i][j]=-1010000000000000000; } dp[i][j]=0; } dp[0][0]=0; int num=1; TRAV(i,transactions){ for(int c=0;c<=cores;c++){ dp[num][c]=dp[num-1][c]; } int curCores=i.cores; for(int c=0;c<=cores;c++){ int left=c-i.cores; if(left>=0 && left<=cores && dp[num-1][left]!=(-1010000000000000000)){ dp[num][c]=max(dp[num][c],dp[num-1][left]+i.profit); // if(dp[num][c]==4550){ // cout<<"DJIOEWJODE "<<c<<" "<<dp[num-1][left]<<" "<<left<<endl; // } } } num++; } // FOR0(i,transactions.size()+1){ // FOR0(j,cores+1){ // cout<<dp[i][j]<<" "; // } // cout<<endl<<endl<<endl; // } int ans=0; FOR0(i,cores+1){ ans=max(ans,dp[transactions.size()][i]); } cout<<ans<<endl; return 0; }

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

clo.cpp: In function 'int32_t main()':
clo.cpp:19:40: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<transaction>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 | #define FOR(i,a,b) for (int i = (a); i < (b); ++i)
      |                                        ^
clo.cpp:20:19: note: in expansion of macro 'FOR'
   20 | #define FOR0(i,a) FOR(i,0,a)
      |                   ^~~
clo.cpp:65:2: note: in expansion of macro 'FOR0'
   65 |  FOR0(i,transactions.size()+1){
      |  ^~~~
clo.cpp:69:9: error: 'j' was not declared in this scope
   69 |   dp[i][j]=0;
      |         ^
clo.cpp:77:7: warning: unused variable 'curCores' [-Wunused-variable]
   77 |   int curCores=i.cores;
      |       ^~~~~~~~