제출 #1095179

#제출 시각아이디문제언어결과실행 시간메모리
1095179TVSownCloud Computing (CEOI18_clo)C++17
100 / 100
888 ms2164 KiB
///*** Sown_Vipro ***/// /// ->GIAI BA QUOC GIA<- /// #include<bits/stdc++.h> using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("popcnt") #define F first #define S second #define pb push_back #define pi pair<int, int> #define pii pair<int, pair<int, int> > #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin); #define out(name) if(fopen(name, "w")) freopen(name, "w", stdout); #define szz(s) int(s.size()) #define int long long const int N = 1e5 + 5, MAX = 1e6, oo = 1e9 + 5, MOD = 1e9 + 7; int n, m, mx; long long res; struct node{ int c, f, v; } t[N]; long long dp[2][N]; bool cmp(node a, node b){ if(a.f != b.f) return a.f > b.f; return a.v < b.v; } void solve(){ cin >> n; for(int i = 1; i <= n; ++i){ int c, f, v; cin >> c >> f >> v; t[i] = {c, f, -v}; mx += c; } cin >> m; for(int i = n + 1; i <= n + m; ++i){ int c, f, v; cin >> c >> f >> v; t[i] = {-c, f, v}; } n += m; sort(t + 1, t + 1 + n, cmp); for(int C = 1; C <= mx; ++C) dp[0][C] = -1e18; for(int i = 1; i <= n; ++i){ auto [c, f, v] = t[i]; // cout << c << " " << f << " " << v << "\n"; for(int C = 1; C <= mx; ++C) dp[i % 2][C] = -1e18; for(int C = mx; C >= 0; --C){ dp[i % 2][C] = dp[1 - (i % 2)][C]; if(C - c >= 0 && C - c <= mx){ dp[i % 2][C] = max(dp[i % 2][C], dp[1 - (i % 2)][C - c] + v); // cout << C << " " << dp[i % 2][C] << "\n"; res = max(res, dp[i % 2][C]); } } } cout << res; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); inp("in.txt"); int t = 1; // cin >> t; while(t--){ solve(); } }

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

clo.cpp: In function 'int main()':
clo.cpp:14:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 | #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
      |                                        ~~~~~~~^~~~~~~~~~~~~~~~~~
clo.cpp:66:5: note: in expansion of macro 'inp'
   66 |     inp("in.txt");
      |     ^~~
#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...