Submission #1091268

#TimeUsernameProblemLanguageResultExecution timeMemory
1091268nghiaaaCloud Computing (CEOI18_clo)C++14
54 / 100
546 ms1948 KiB
#include <bits/stdc++.h> using namespace std; //variable #define ld long double #define ll long long #define db double #define ii pair<int,int> #define f first #define s second #define mp make_pair #define mt make_tuple //vector #define pb push_back #define all(v) v.begin(),v.end() #define len(a) (int)a.length() #define sz(a) (int)a.size() //mask #define BIT(i) (1LL<<(i)) //better code, debugger #define watch(n) cerr << #n << ": " << n << endl #define debug(x) for (auto p: x) cerr<<p<<' ';cerr<<endl #define forw(i,j,z) for(int i=(int)j;i<=(int)z;i++) #define ford(i,j,z) for (int i=(int)j;i>=(int)z;i--) #define fIlE "test." //auto seed = chrono::high_resolution_clock::now().time_since_epoch().count(); //mt19937 RAND(seed); const int mod = 998244353; inline int add(int u,int v){u+=v;if(u>=mod)u-=mod;return u;} inline int dec(int u,int v){u-=v;if(u<0)u+=mod;return u;} inline int mul(int u,int v){return (ll)u*v%mod;} const int N = 2000 + 1; struct E{ int slot, tt, cost; }; E a[2 * N]; bool cmp(E u, E v) { if (u.tt != v.tt) return u.tt > v.tt; return u.slot < v.slot; } int n, m; void solve() { cin >> n; int maxC = 0; forw(i, 1, n){ cin >> a[i].slot >> a[i].tt >> a[i].cost; a[i].cost *= -1; maxC += a[i].slot; } cin >> m; forw(i, n + 1, n + m){ cin >> a[i].slot >> a[i].tt >> a[i].cost; a[i].slot *= -1; } sort(a + 1, a + n + m + 1, cmp); vector<ll> dp(maxC + 1, LLONG_MIN); dp[0] = 0; forw(i, 1, n + m){ const E u = a[i]; vector<ll> re(dp); forw(c, 0, maxC) if (c + u.slot >= 0 && c + u.slot <= maxC && dp[c] != LLONG_MIN) re[c + u.slot] = max(re[c + u.slot], dp[c] + u.cost); dp = re; } cout << *max_element(all(dp)); } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); if (fopen(fIlE"inp", "r")) freopen(fIlE"inp","r",stdin), freopen(fIlE"out","w",stdout); //time_t TIME_TU=clock(); int t=1; // cin>>t; while(t--) solve(); //time_t TIME_TV=clock(); //cerr<<(db)(TIME_TV-TIME_TU)/CLOCKS_PER_SEC<<endl; return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:75:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         freopen(fIlE"inp","r",stdin), freopen(fIlE"out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
clo.cpp:75:46: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         freopen(fIlE"inp","r",stdin), freopen(fIlE"out","w",stdout);
      |                                       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#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...