Submission #502187

#TimeUsernameProblemLanguageResultExecution timeMemory
502187RambaXGorillaCloud Computing (CEOI18_clo)C++17
100 / 100
715 ms2184 KiB
#include<cstdio> #include<algorithm> #include<functional> #include<vector> using namespace std; typedef long long ll; int N, M; vector <int> comps[4010]; ll curr[100001]; ll next_[100001] = {}; int main(){ scanf("%d",&N); for(int i = 0;i < N;i++){ comps[i] = vector <int> (4); scanf("%d%d%d",&comps[i][2],&comps[i][0],&comps[i][3]); comps[i][1] = 1; } scanf("%d",&M); for(int i = N;i < N + M;i++){ comps[i] = vector <int> (4); scanf("%d%d%d",&comps[i][2],&comps[i][0],&comps[i][3]); comps[i][1] = 0; } sort(comps, comps + N + M, greater <vector <int>> ()); for(int i = N + M - 1;i > -1;i--){ for(int j = 0;j < 100001;j++){ if(comps[i][1]){ curr[j] = max(next_[j], next_[min(comps[i][2] + j, 100000)] - comps[i][3]); } else{ curr[j] = next_[j]; if(j >= comps[i][2]){ curr[j] = max(curr[j], next_[j - comps[i][2]] + comps[i][3]); } } } copy(curr, curr + 100001, next_); } printf("%lld",curr[0]); }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
clo.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%d%d%d",&comps[i][2],&comps[i][0],&comps[i][3]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d",&M);
      |     ~~~~~^~~~~~~~~
clo.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%d%d%d",&comps[i][2],&comps[i][0],&comps[i][3]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...