Submission #994481

#TimeUsernameProblemLanguageResultExecution timeMemory
994481cpdreamerCloud Computing (CEOI18_clo)C++14
18 / 100
28 ms1372 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <utility> using namespace __gnu_pbds; using namespace std; typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set; const int max_n=INT_MAX; typedef long long ll; #define LLM LONG_LONG_MAX #define pb push_back #define F first #define L length() #define all(v) v.begin(),v.end() #define V vector #define S second const long long MOD = 1000000007; // 1e9 + 7 void file(){ freopen("input.txt.txt","r",stdin); freopen("output.txt.txt","w",stdout); } void setio(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } void solve(){ int n; cin>>n; pair<int,int>A[n+1]; int Per[n+1],P[n+1]; for(int i=1;i<=n;i++){ int b; cin>>b>>A[i].F>>A[i].S; } sort(A+1,A+n+1); for(int i=1;i<=n;i++){ Per[i]=A[i].F; P[i]=A[i].S; } int m;cin>>m; pair<int,int>B[m+1]; int Per1[m+1],P1[m+1]; for(int i=1;i<=m;i++){ int b; cin>>b>>B[i].F>>B[i].S; } sort(B+1,B+1+m); for(int i=1;i<=m;i++){ Per1[i]=B[i].F; P1[i]=B[i].S; } ll dp[n+1][m+1]; memset(dp,0,sizeof(dp)); for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ //dp[i][j]=buy form first i and sell to first j for(int g=j;g>=1;g--){ ll c=dp[i-1][g-1]; if(Per[i]>=Per1[g]) c+=P1[g]-P[i]; dp[i][j]=max(dp[i][j],c); dp[i][j]=max(dp[i][j],max(dp[i-1][j],dp[i][j-1])); } } } cout<<dp[n][m]<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //file(); solve(); return 0; }

Compilation message (stderr)

clo.cpp: In function 'void file()':
clo.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     freopen("input.txt.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen("output.txt.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp: In function 'void setio(std::string)':
clo.cpp:25:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((s + ".out").c_str(), "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...