제출 #996548

#제출 시각아이디문제언어결과실행 시간메모리
996548cpdreamerCloud Computing (CEOI18_clo)C++17
100 / 100
279 ms1428 KiB
#include <bits/stdc++.h> #include <climits> #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 = 99824433; // 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); } struct computer{ int c; int p; int v; int id; }; bool sorted(computer a,computer b){ if(a.p==b.p) return a.id<b.id; return a.p>b.p; } void solve() { int n; cin>>n; V<computer>A; for(int i=0;i<n;i++){ int a,b,c; cin>>a>>b>>c; A.pb({a,b,c,-1}); } int m; cin>>m; for(int i=0;i<m;i++){ int a,b,c; cin>>a>>b>>c; A.pb({a,b,c,i}); } sort(all(A),sorted); ll dp[100001]; bool made[100001]; for(int i=0;i<100001;i++) dp[i]=-1e18; dp[0]=0; for(int i=0;i<n+m;i++){ if(A[i].id==-1){ for(int j=100000;j>=A[i].c;j--){ dp[j]=max(dp[j],dp[j-A[i].c]-A[i].v); } } else{ for(int j=0;j<=100000-A[i].c;j++){ dp[j]=max(dp[j],dp[j+A[i].c]+A[i].v); } } int k; k++; } ll ans=-1; for(int i=0;i<=100000;i++) ans=max(ans,dp[i]); cout<<ans<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //file(); solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

clo.cpp: In function 'void solve()':
clo.cpp:58:10: warning: unused variable 'made' [-Wunused-variable]
   58 |     bool made[100001];
      |          ^~~~
clo.cpp: In function 'void file()':
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("input.txt.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     freopen("output.txt.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp: In function 'void setio(std::string)':
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 + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     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...