MAGCARI

Guitar

Oct 29th, 2022
982
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. /*
  2.     Task    : Guitar
  3.     Author  : Phumipat C. [MAGCARI]
  4.     Language: C++
  5.     Created : 29 October 2022 [14:45]
  6. */
  7. #include<bits/stdc++.h>
  8. using namespace std;
  9. vector<pair<int ,int > > v[5];
  10. int pt[5];
  11. int main(){
  12.     cin.tie(0)->sync_with_stdio(0);
  13.     cin.exceptions(cin.failbit);
  14.     int n,t,type,atk;
  15.     cin >> n >> t;
  16.     for(int i=1;i<=n;i++){
  17.         cin >> type >> atk;
  18.         v[type].push_back({atk,i});
  19.     }
  20.     for(int i=1;i<=t;i++)
  21.         sort(v[i].begin(),v[i].end());
  22.     int q;
  23.     cin >> q;
  24.     while(q--){
  25.         for(int i=1;i<=t;i++)
  26.             cin >> pt[i];
  27.         int i,j,k;
  28.         i = j = k = 0;
  29.         for(int x=1;x<=n;x++){
  30.             pair<int ,int > ans = {2e9,2e9};
  31.             //first min atk, second type
  32.             if(t>=1 && i<v[1].size()){
  33.                 ans = min(ans,{v[1][i].first-pt[1],1});
  34.             }
  35.             if(t>=2 && j<v[2].size()){
  36.                 ans = min(ans,{v[2][j].first-pt[2],2});
  37.             }
  38.             if(t>=3 && k<v[3].size()){
  39.                 ans = min(ans,{v[3][k].first-pt[3],3});
  40.             }
  41.             if(ans.second == 1){
  42.                 cout << v[1][i].second << ' ';
  43.                 i++;
  44.             }else if(ans.second == 2){
  45.                 cout << v[2][j].second << ' ';
  46.                 j++;
  47.             }else if(ans.second == 3){
  48.                 cout << v[3][k].second << ' ';
  49.                 k++;
  50.             }
  51.         }
  52.         cout << '\n';
  53.     }
  54.     return 0;
  55. }
  56. /*
  57. 7 3
  58. 1 10
  59. 2 8
  60. 3 5
  61. 1 3
  62. 2 15
  63. 3 12
  64. 3 4
  65. 2
  66. 8 3 1
  67. 0 5 2
  68. */
Advertisement
Add Comment
Please, Sign In to add comment