Submission #667569

#TimeUsernameProblemLanguageResultExecution timeMemory
667569AugustynCloud Computing (CEOI18_clo)C++14
100 / 100
300 ms1208 KiB
#include<bits/stdc++.h> using namespace std; #define takt first #define cena second.first #define ilerdz second.second int n,m,lacz_rdz,najw_rdz; pair<int,pair<int,int>>je_kalk[2001],klient[2001]; long long dp[100001]; int main() { scanf("%d",&n); for(int i=1;i<=n;++i) { scanf("%d%d%d",&je_kalk[i].ilerdz,&je_kalk[i].takt,&je_kalk[i].cena); lacz_rdz+=je_kalk[i].ilerdz; } scanf("%d",&m); for(int i=1;i<=m;++i) { scanf("%d%d%d",&klient[i].ilerdz,&klient[i].takt,&klient[i].cena); } sort(je_kalk+1,je_kalk+n+1); sort(klient+1,klient+m+1); for(int i=1;i<=lacz_rdz;++i) dp[i]=LONG_LONG_MIN; while(m) { while(n) { if(je_kalk[n].takt<klient[m].takt) break; for(int i=najw_rdz+je_kalk[n].ilerdz;i>=je_kalk[n].ilerdz;--i) { if(dp[i-je_kalk[n].ilerdz]!=LONG_LONG_MIN) dp[i]=max(dp[i],dp[i-je_kalk[n].ilerdz]-je_kalk[n].cena); } najw_rdz+=je_kalk[n].ilerdz; --n; } for(int i=0;i<=najw_rdz-klient[m].ilerdz;++i) { if(dp[i+klient[m].ilerdz]!=LONG_LONG_MIN) dp[i]=max(dp[i],dp[i+klient[m].ilerdz]+klient[m].cena); } --m; } long long odp=0; for(int i=0;i<=lacz_rdz;++i) odp=max(odp,dp[i]); printf("%lld",odp); return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
clo.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d%d%d",&je_kalk[i].ilerdz,&je_kalk[i].takt,&je_kalk[i].cena);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d",&m);
      |  ~~~~~^~~~~~~~~
clo.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%d%d%d",&klient[i].ilerdz,&klient[i].takt,&klient[i].cena);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...