#include<iostream> #include<vector> #include<algorithm> class fight{ public: int mID; int mdamage; int mpoweradd; int profit; bool operator < (const fight& f) const{ return (mpoweradd > f.mpoweradd); } }; using namespace std; main(){ int n,z; int dam,pow; int DAM,POW; vector<fight>WF; fight F; cin >> n; cin >> z; POW=z; DAM=0; for(int i=0;i<n;i++){ cin >> dam; cin >> pow; DAM+=dam; POW+=pow; F.mID=i+1; F.mdamage=dam; F.mpoweradd=pow; F.profit=pow-dam; WF.push_back(F); } if(DAM>POW){ cout << "NIE" << endl; return 0; } sort(WF.begin(),WF.end()); cout << "TAK" << endl; for (int i=0;i<n;i++) cout << WF[i].mID << " "; cout << endl; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #include<iostream> #include<vector> #include<algorithm> class fight{ public: int mID; int mdamage; int mpoweradd; int profit; bool operator < (const fight& f) const{ return (mpoweradd > f.mpoweradd); } }; using namespace std; main(){ int n,z; int dam,pow; int DAM,POW; vector<fight>WF; fight F; cin >> n; cin >> z; POW=z; DAM=0; for(int i=0;i<n;i++){ cin >> dam; cin >> pow; DAM+=dam; POW+=pow; F.mID=i+1; F.mdamage=dam; F.mpoweradd=pow; F.profit=pow-dam; WF.push_back(F); } if(DAM>POW){ cout << "NIE" << endl; return 0; } sort(WF.begin(),WF.end()); cout << "TAK" << endl; for (int i=0;i<n;i++) cout << WF[i].mID << " "; cout << endl; return 0; } |