제출 #996454

#제출 시각아이디문제언어결과실행 시간메모리
996454cpdreamerCloud Computing (CEOI18_clo)C++17
36 / 100
126 ms160004 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 = 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; }; bool sorted(computer a,computer b){ return a.p>b.p; } void solve() { int n; cin >> n; V<computer> A; A.pb({0, 0, 0}); ll sum=0; for (int i = 0; i < n; i++) { int a, b, c; cin >> a >> b >> c; sum+=a; A.pb({a, b, -c}); } int m; cin >> m; for (int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; A.pb({-a, b, c}); } sort(A.begin()+1,A.end(), sorted); ll dp[n + m + 1][10100]; memset(dp, -1, sizeof(dp)); dp[0][0]=0; for (int i = 1; i <= n + m; i++) { for (int j =0; j <= 10000; j++) dp[i][j] = dp[i - 1][j]; for (int j = max(0, A[i].c); j <=min(10000,10000-A[i].c) ; j++) { if (dp[i - 1][j - A[i].c] != -1) { if (dp[i][j] != -1) dp[i][j] = max(dp[i][j], dp[i - 1][j - A[i].c] + A[i].v); else dp[i][j] = dp[i - 1][j - A[i].c] + A[i].v; } } int k; k++; } cout << *max_element(dp[n + m], dp[n + m] +10001) << 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 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...