传送门:https://codeforces.com/contest/1816/problem/B
给个题面看看
题意:给你1-2n个数字放在一个2*n的网格中,从(1,1)走到(2,n)求花费路径的最小值的最大化,定义花费是
即花费为a[i]*(-1)^(-1+i)
要使的花费最小,就是要加的大,减的少(开源节流)
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <list>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#define IOS() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
#define fir(v) (v).first
#define se(v) (v).second
#define pb(x) push_back(x)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define pii pair<int,int>
#define all(a) (a).begin(),(a).end()
#define mp(a,b) make_pair(a,b)
using namespace std;
const int N=1000000;
int a[3][2000006];//数组第二个要开的大一点
bool cmp(int x,int y)
{
return x>y;
}
signed main()
{
IOS();
int t ;
cin>>t;
while(t--){
int n;
cin>>n;
a[1][1]=2*n;//(1,1)的值放最大
for(int i=1;i<=n;i++){
if(i%2==1){
a[2][i]=i;//第二行的奇数位置
a[2][i+1]=i+n;//第二行的偶数位置
}
else {//偶数位置
a[1][i]=i;//第一行的偶数位置
a[1][i+1]=i+n;//第一行的奇数位置
}
}
for(int i=1;i<=2;i++){//输出
for(int j=1;j<=n;j++){
cout<<a[i][j]<<" ";
}
cout<<endl;
}
}
}