제출 #431008

#제출 시각아이디문제언어결과실행 시간메모리
431008Runtime_error_Cloud Computing (CEOI18_clo)C++14
100 / 100
818 ms2060 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const ll N = 2009,C = 55,MX = 1e18+9; ll n,m,SumCores,ans; ll dp[2][N*C]; struct item{ ll type;//1 costumer 2 computer ll clock;//sort decreasingly and forget about it ll cores;//the knapsack size, + for computers, - for costumers, keep this >=0 ll price;// - for computers, + for costumers: maximize this bool operator<(const item &other)const { if(clock == other.clock) return type > other.type; return clock > other.clock; } }a[N<<1]; signed main(){ scanf("%lld",&n); for(ll i=1;i<=n;i++) scanf("%lld%lld%lld",&a[i].cores,&a[i].clock,&a[i].price), a[i].type = 2, a[i].price*=-1, SumCores += a[i].cores; scanf("%d",&m); for(ll i=n+1;i<=n+m;i++) scanf("%d%d%d",&a[i].cores,&a[i].clock,&a[i].price), a[i].type = 1, a[i].cores *= -1; sort(a+1,a+1+n+m); bool is = 0; for(ll j=1;j<=SumCores;j++) dp[is][j] = -MX; for(ll i=1;i<=n+m;i++){ is = !is; for(ll j=0;j<=SumCores;j++){ dp[is][j] = dp[!is][j]; if(j - a[i].cores >= 0 && j-a[i].cores <= SumCores) dp[is][j] = max(dp[is][j],dp[!is][j-a[i].cores] + a[i].price); //cout<<i<<" "<<j<<" "<<dp[i][j]<<endl; ans = max(ans,dp[is][j]); } } printf("%lld\n",ans); } /* 2 4 2200 700 4 2000 750 2 1 1500 300 6 1900 1500 */

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

clo.cpp: In function 'int main()':
clo.cpp:30:13: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   30 |     scanf("%d",&m);
      |            ~^  ~~
      |             |  |
      |             |  long long int*
      |             int*
      |            %lld
clo.cpp:32:17: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   32 |         scanf("%d%d%d",&a[i].cores,&a[i].clock,&a[i].price),
      |                ~^      ~~~~~~~~~~~
      |                 |      |
      |                 int*   long long int*
      |                %lld
clo.cpp:32:19: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   32 |         scanf("%d%d%d",&a[i].cores,&a[i].clock,&a[i].price),
      |                  ~^                ~~~~~~~~~~~
      |                   |                |
      |                   int*             long long int*
      |                  %lld
clo.cpp:32:21: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'long long int*' [-Wformat=]
   32 |         scanf("%d%d%d",&a[i].cores,&a[i].clock,&a[i].price),
      |                    ~^                          ~~~~~~~~~~~
      |                     |                          |
      |                     int*                       long long int*
      |                    %lld
clo.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
clo.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |         scanf("%lld%lld%lld",&a[i].cores,&a[i].clock,&a[i].price),
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     scanf("%d",&m);
      |     ~~~~~^~~~~~~~~
clo.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         scanf("%d%d%d",&a[i].cores,&a[i].clock,&a[i].price),
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...