結果

問題 No.397 NO MORE KADOMATSU
ユーザー tntantntan
提出日時 2016-07-15 23:14:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 1,073 ms
コンパイル使用メモリ 147,816 KB
実行使用メモリ 24,420 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 00:16:32
合計ジャッジ時間 2,700 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,676 KB
testcase_01 AC 23 ms
23,700 KB
testcase_02 AC 20 ms
23,892 KB
testcase_03 AC 23 ms
24,360 KB
testcase_04 AC 20 ms
24,168 KB
testcase_05 AC 21 ms
23,796 KB
testcase_06 AC 24 ms
23,664 KB
testcase_07 AC 24 ms
23,568 KB
testcase_08 AC 22 ms
24,048 KB
testcase_09 AC 19 ms
23,652 KB
testcase_10 AC 41 ms
24,420 KB
testcase_11 AC 19 ms
24,048 KB
testcase_12 AC 27 ms
24,036 KB
testcase_13 AC 30 ms
24,300 KB
testcase_14 AC 31 ms
24,060 KB
testcase_15 AC 30 ms
23,460 KB
testcase_16 AC 20 ms
23,592 KB
testcase_17 AC 22 ms
23,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int n,a[105],dummy;
vector<pii>v;

void Sort(int a[],int n)
{
	bool flag=true;
	for(int i=0;flag;i++)
	{
		flag=false;
		for(int j=n-1;j>=i;j--)
		if(a[j]<a[j-1])
		{
			swap(a[j],a[j-1]);
			v.pb(mp(j,j-1));
			flag=true;
		}
	}
}

int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	Sort(a,n);
	cout<<v.size()<<endl;
	for(int i=0;i<v.size();i++)cout<<v[i].fi<<" "<<v[i].se<<endl;
	cin>>dummy;
	return 0;
}
0