제출 #400293

#제출 시각아이디문제언어결과실행 시간메모리
400293SavicSCloud Computing (CEOI18_clo)C++14
36 / 100
740 ms4164 KiB
#include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define ff(i,a,b) for(int i=a;i<=b;i++) #define fb(i,b,a) for(int i=b;i>=a;i--) using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef pair<int,int> pii; const int maxn = 2005; const ll inf = 1e18 + 5; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // os.order_of_key(k) the number of elements in the os less than k // *os.find_by_order(k) print the k-th smallest number in os(0-based) int n, m; vector<array<int,4>> vec; bool cmp(array<int,4> s1, array<int,4> s2){ if(s1[1] == s2[1])return s1[4] > s2[4]; return s1[1] > s2[1]; } const int N = 104260; ll dp[2][N + 5]; int main() { ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr); cin >> n; ff(i,1,n){ int A, B, C; cin >> A >> B >> C; vec.pb({A, B, C, 1}); } cin >> m; ff(i,1,m){ int A, B, C; cin >> A >> B >> C; vec.pb({A, B, C, 0}); } sort(all(vec), cmp); ff(i,0,N)dp[0][i] = dp[1][i] = -inf; dp[0][0] = 0; ff(i,0,sz(vec) - 1){ int A = vec[i][0]; int B = vec[i][1]; int C = vec[i][2]; int T = vec[i][3]; int cur = (i + 1) % 2; int pre = i % 2; if(T == 1){ ff(j,0,N){ dp[cur][j] = dp[pre][j]; // ako uzimam i-ti objekat if(j >= A)dp[cur][j] = max(dp[cur][j], dp[pre][j - A] - C); } } else{ ff(j,0,N){ dp[cur][j] = dp[pre][j]; if(j + A <= N)dp[cur][j] = max(dp[cur][j], dp[pre][j + A] + C); } } } ll rez = 0; ff(j,0,N)rez = max(rez, dp[(n + m) % 2][j]); cout << rez << endl; return 0; } /** 4 4 2200 700 2 1800 10 20 2550 9999 4 2000 750 3 1 1500 300 6 1900 1500 3 2400 4550 // probati bojenje sahovski ili slicno **/

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

clo.cpp: In function 'int main()':
clo.cpp:62:13: warning: unused variable 'B' [-Wunused-variable]
   62 |         int B = vec[i][1];
      |             ^
#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...