CodeForces 1992C Gorilla and Permutation

题目链接:CodeForces 1992C【Gorilla and Permutation】



思路

       根据题意只需要使得f(x)尽可能大,g(x)尽可能小,所以需要将大于等于n的数组排在序列的前端,且按由大到小的顺序依次排列,将小于等于m的数字排在序列的后端,且按从小到大的顺序依次排列。


代码

#include <functional>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
const int N = 500 + 10;

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = n; i > m; i--) {
      cout << i << " ";
    }
    for (int i = 1; i <= m; i++) {
      cout << i << " ";
    }
    cout << endl;
  }
  return 0;
}
posted @ 2024-07-16 13:45  薛定谔的AC  阅读(7)  评论(0编辑  收藏  举报