521D
There are three strategies for upgrading skills: 1, =; 2, +=;3, *=. The optimal order of upgrades is obviously first using strategy 1, then strategy 2, and then strategy 3.
Assignment increment (for each skill only considers the maximum gain assignment operation), plus the multiply (for each skill to give priority to the maximum gain of the addition), in the premise of not exceeding the overall upgrade scheme, the selection of M-type of the largest multiplier of the upgrade scheme. Since the original scheme is a multiplication scheme, the first number of times will not affect the final result, so only the M scheme can be processed into a legal order (according to the type of strategy; The original scheme is the same as the addition scheme)
1#include"iostream"2#include"Cstdio"3#include"CString"4#include"Vector"5#include"Utility"6#include"algorithm"7 using namespacestd;8vector<int>A;9 intt[100005][3];Tenvector<pair<int,int> >T1; Onevector<vector<pair<int,int> > >T2; Avector<pair<Double,int> >T3; -vector<pair<int,int> >Sol; - intk, N, M; the - intMain () - { - intI, J; +scanf"%d%d%d", &k, &n, &m); -A.resize (k +1); +T1.resize (k +1); AT2.resize (k +1); at for(i =1; I <= K; ++i) { -scanf"%d", &a[i]); - } - for(i =1; I <= N; ++i) { -scanf"%d%d%d", &t[i][0], &t[i][1], &t[i][2]); - Switch(t[i][0]) { in Case 1: - if(t1[t[i][1]].first < t[i][2]) { tot1[t[i][1]].first = t[i][2]; +t1[t[i][1]].second =i; - } the Break; * Case 2: $t2[t[i][1]].push_back (Make_pair (t[i][2], i));Panax Notoginseng Break; - Case 3: theT3.push_back (Make_pair (t[i][2], i)); + } A } the /*For (i = 1; I <= K; ++i) { + printf ("T1%d%d\n", T1[i].first, T1[i].second); - For (j = 0; J < t2[i].size (); ++j) $ printf ("T2%d%d\n", T2[i][j].first, T2[i][j].second); $ } - For (i = 0; i < t3.size (); ++i) - printf ("T3%lf%d\n", T3[i].first, T3[i].second);*/ the - for(i =1; I <= K; ++i) {Wuyi if(T1[i].first >A[i]) { theT2[i].push_back (Make_pair (T1[i].first-A[i], t1[i].second)); - //printf ("Zhuan%d%d\n", Make_pair (T1[i].first-a[i], T1[i].second). First, Make_pair (T1[i].first-a[i], t1[i]. Second). second); Wu } - sort (T2[i].begin (), T2[i].end ()); About Doublesum =A[i]; $ for(j = t2[i].size ()-1; J >=0; --j) { -T3.push_back (Make_pair (sum + t2[i][j].first)/sum, T2[i][j].second)); -Sum + =T2[i][j].first; - } A } + sort (T3.begin (), T3.end ()); the /*For (i = t3.size ()-1; I >= 0; i.) - printf ("T3%f%d\n", T3[i].first, T3[i].second);*/ $ them = min (M, (int) t3.size ()); the for(i = t3.size ()-1; I >= (int) T3.size ()-M; --i) { theSol.push_back (Make_pair (t[t3[i].second][0], T3[i].second)); the } - sort (Sol.begin (), Sol.end ()); inprintf"%d\n", m); the if(m) { theprintf"%d", sol[0].second); About for(i =1; I <= M-1; ++i) { theprintf"%d", Sol[i].second); the } theprintf"\ n"); + } -}
Codeforces 521D Nice Greedy