Submission #448792

#TimeUsernameProblemLanguageResultExecution timeMemory
448792YuisuyunoCloud Computing (CEOI18_clo)C++14
100 / 100
2879 ms5408 KiB
#include <bits/stdc++.h> #define sz(x) int(x.size()) #define all(x) x.begin(),x.end() #define reset(x) memset(x, 0,sizeof(x)) #define pb push_back #define mp make_pair #define fi first #define se second #define N 2005 #define remain(x) if (x > MOD) x -= MOD #define ii pair<int, int> #define iii pair<int, ii> #define iiii pair< ii , ii > #define viiii vector< iiii > #define vi vector<int> #define vii vector< ii > #define bit(x, i) (((x) >> (i)) & 1) #define Task "test" #define int long long using namespace std; typedef long double ld; const int inf = 1e12; const int minf = -1e10; int n, m; vector<iii> a; void readfile() { ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); if (fopen(Task".inp","r")) { freopen(Task".inp","r",stdin); //freopen(Task".out","w",stdout); } cin >> n; for(int i=1; i<=n; i++){ int cnt, fre, cost; cin >> cnt >> fre >> cost; cost*=-1; a.pb(iii(fre,ii(cnt,cost))); } cin >> m; for(int i=1; i<=m; i++){ int cnt, fre, cost; cin >> cnt >> fre >> cost; cnt*=-1; a.pb({fre,{cnt,cost}}); } } void proc() { sort(a.rbegin(),a.rend()); vector<int> dp{0}; for(int i=0; i<a.size(); i++){ vector<int> dp2 = dp; for(int j=0; j<dp.size(); j++){ int cnt = j + a[i].se.fi; int cost = dp[j] + a[i].se.se; if (cnt >= 0){ while (dp2.size() <= cnt) dp2.pb(minf*2000); dp2[cnt] = max(dp2[cnt],cost); } } dp = dp2; } int ans = 0; for(int i=0; i<dp.size(); i++) ans = max(ans,dp[i]); cout << ans; } signed main() { readfile(); proc(); return 0; }

Compilation message (stderr)

clo.cpp: In function 'void proc()':
clo.cpp:59:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int i=0; i<a.size(); i++){
      |                  ~^~~~~~~~~
clo.cpp:61:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for(int j=0; j<dp.size(); j++){
      |                      ~^~~~~~~~~~
clo.cpp:65:35: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   65 |                 while (dp2.size() <= cnt) dp2.pb(minf*2000);
      |                        ~~~~~~~~~~~^~~~~~
clo.cpp:72:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |     for(int i=0; i<dp.size(); i++) ans = max(ans,dp[i]);
      |                  ~^~~~~~~~~~
clo.cpp: In function 'void readfile()':
clo.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen(Task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...