Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Task : Guitar
- Author : Phumipat C. [MAGCARI]
- Language: C++
- Created : 29 October 2022 [14:45]
- */
- #include<bits/stdc++.h>
- using namespace std;
- vector<pair<int ,int > > v[5];
- int pt[5];
- int main(){
- cin.tie(0)->sync_with_stdio(0);
- cin.exceptions(cin.failbit);
- int n,t,type,atk;
- cin >> n >> t;
- for(int i=1;i<=n;i++){
- cin >> type >> atk;
- v[type].push_back({atk,i});
- }
- for(int i=1;i<=t;i++)
- sort(v[i].begin(),v[i].end());
- int q;
- cin >> q;
- while(q--){
- for(int i=1;i<=t;i++)
- cin >> pt[i];
- int i,j,k;
- i = j = k = 0;
- for(int x=1;x<=n;x++){
- pair<int ,int > ans = {2e9,2e9};
- //first min atk, second type
- if(t>=1 && i<v[1].size()){
- ans = min(ans,{v[1][i].first-pt[1],1});
- }
- if(t>=2 && j<v[2].size()){
- ans = min(ans,{v[2][j].first-pt[2],2});
- }
- if(t>=3 && k<v[3].size()){
- ans = min(ans,{v[3][k].first-pt[3],3});
- }
- if(ans.second == 1){
- cout << v[1][i].second << ' ';
- i++;
- }else if(ans.second == 2){
- cout << v[2][j].second << ' ';
- j++;
- }else if(ans.second == 3){
- cout << v[3][k].second << ' ';
- k++;
- }
- }
- cout << '\n';
- }
- return 0;
- }
- /*
- 7 3
- 1 10
- 2 8
- 3 5
- 1 3
- 2 15
- 3 12
- 3 4
- 2
- 8 3 1
- 0 5 2
- */
Advertisement
Add Comment
Please, Sign In to add comment