Edu-179-D. Creating a Schedule · znzryb
## 思路讲解
这道D题确实不算太难,我赛时应该也是可以写出来的。
采用类似于下图的构造方式即可

## AC代码
[https://codeforces.com/contest/2111/submission/322856069](https://codeforces.com/contest/2111/submission/322856069)
::: 源代码
```cpp
// Problem: D. Creating a Schedule D. 创建时间表
// Contest: Codeforces - Educational Codeforces Round 179 (Rated for Div. 2)教育 Codeforces 第 179 轮(评级为 Div. 2)
// URL: https://codeforces.com/contest/2111/problem/D
// Memory Limit: 512 MB
// Time Limit: 2500 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define fi first
#define se second
#define pb push_back
#define SZ(a) ((int) a.size())
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define ROF(i, a, b) for (int i = (a); i >= (b); --i)
// #define getFro(vec) (vec.empty()?0:vec.front())
// #define getBac(vec) (vec.empty()?0:vec.back())
#define debug(var) cerr << #var <<":"<<var<<"\n";
// #define DEBUG(variable) do { std::cerr << #variable << ":"; for (const auto& elem : \
// variable) { std::cerr << elem << " ";}std::cerr << "\n";} while (0)
// #define uniVec(var) do { sort(var.begin(),var.end());var.resize(unique(var.begin(), \
// var.end())-var.begin());} while (0)
// #define debugN(var,N) do{ std::cerr<<#var<<":"; FOR(i,1,N){ std::cerr<<var[i]<<" "; } \
// std::cerr<<"\n"; }while(0)
// #define debugMap(variable) do { std::cerr << #variable << ":\n"; for (const auto \
// & pair : variable) \
// { std::cerr << " " << pair.first << " => " << pair.second << "\n"; } \
// std::cerr << std::endl; } while (0)
#define lson(var) (var<<1)
#define rson(var) ((var<<1)+1)
// #define vecMxx(vec,x) (vec.end()-lower_bound(all(vec),x)) // vec中大于x的数有几个
using namespace std;
typedef long long ll;typedef unsigned long long ull;
typedef double DB;typedef long double LD;
typedef __int128 i128;typedef pair<DB,DB> pdd;typedef pair<ll,bool> plb;
typedef pair<ll,ll> pll;
typedef array<ll,3> arr3;typedef array<ll,2> arr2;
constexpr ll MAXN=static_cast<ll>(1e6)+10,INF=static_cast<ll>(1e9)+9; // 1e18+9也是素数
constexpr ll mod=static_cast<ll>(1e9)+7;
constexpr double eps=1e-8;
ll N,M,Q,X,K,lT,A[MAXN];
// ll ans[MAXN][MAXN];
/*
*/
inline void solve(){
scanf("%lld%lld",&N,&M);
FOR(i,1,M){
ll num;
scanf("%lld",&A[i]);
// A[i]=num/100;
}
sort(A+1,A+1+M);
ll beg=0,ed=M+1;
FOR(i,1,N){
if(i%2==1){
++beg;--ed;
FOR(j,1,6){
if(j%2==1) printf("%lld ",A[beg]);
else printf("%lld ",A[ed]);
}
printf("\n");
}else{
FOR(j,1,6){
if(j%2==1) printf("%lld ",A[ed]);
else printf("%lld ",A[beg]);
}
printf("\n");
}
}
}
int main()
{
// ios::sync_with_stdio(false);
// cin.tie(0);cout.tie(0);
scanf("%lld",&lT);
while(lT--){
solve();
}
// solve();
return 0;
}
/*
AC
https://codeforces.com/contest/2111/submission/322856069
*/
```
:::
## 心路历程(WA,TLE,MLE……)