結果

問題 No.831 都市めぐり
ユーザー furafura
提出日時 2020-05-23 06:56:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 692 bytes
コンパイル時間 3,774 ms
コンパイル使用メモリ 199,764 KB
実行使用メモリ 18,668 KB
最終ジャッジ日時 2023-07-28 20:57:35
合計ジャッジ時間 4,087 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 8 ms
9,620 KB
testcase_16 AC 4 ms
5,784 KB
testcase_17 AC 9 ms
10,796 KB
testcase_18 AC 10 ms
13,184 KB
testcase_19 AC 13 ms
18,256 KB
testcase_20 AC 15 ms
18,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n; scanf("%d",&n);

// experiment
/*
	vector<lint> p(n);
	iota(p.begin(),p.end(),1);
	lint ans=1e7;
	vector<lint> pans;
	do{
		lint cost=0;
		rep(i,n) cost+=p[i]*p[(i+1)%n];
		if(ans>cost){
			ans=cost;
			pans=p;
		}
	}while(next_permutation(p.begin(),p.end()));

	cout<<ans<<endl;
	rep(i,n) cout<<pans[i]<<" "; cout<<endl;
*/

	vector<lint> p(n);
	int a=1,b=n,l=0,r=n-1;
	for(bool f=true;l<=r;f=!f){
		if(f) p[l]=a, p[r]=b;
		else  p[l]=b, p[r]=a;
		a++;
		b--;
		l++;
		r--;
	}

	lint ans=0;
	rep(i,n) ans+=p[i]*p[(i+1)%n];
	printf("%lld\n",ans);

	return 0;
}
0