結果

問題 No.397 NO MORE KADOMATSU
ユーザー ldsybldsyb
提出日時 2016-07-16 00:53:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 437 bytes
コンパイル時間 617 ms
コンパイル使用メモリ 70,580 KB
実行使用メモリ 24,264 KB
平均クエリ数 651.67
最終ジャッジ日時 2023-09-24 00:19:57
合計ジャッジ時間 2,382 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,580 KB
testcase_01 AC 25 ms
23,700 KB
testcase_02 AC 26 ms
23,580 KB
testcase_03 AC 26 ms
24,012 KB
testcase_04 AC 26 ms
23,376 KB
testcase_05 AC 27 ms
24,252 KB
testcase_06 AC 27 ms
23,472 KB
testcase_07 AC 27 ms
23,460 KB
testcase_08 AC 26 ms
23,388 KB
testcase_09 AC 25 ms
24,096 KB
testcase_10 AC 53 ms
23,748 KB
testcase_11 AC 26 ms
23,376 KB
testcase_12 AC 26 ms
24,264 KB
testcase_13 AC 34 ms
23,388 KB
testcase_14 AC 35 ms
23,532 KB
testcase_15 AC 36 ms
24,000 KB
testcase_16 AC 26 ms
23,388 KB
testcase_17 AC 26 ms
23,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int main(){
	vector<pair<int,int>> vp;
	int n,count = 0;
	cin >> n;
	int a[n];
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n;i++){
		for(int j = i + 1;j < n;j++){
			if(a[i] > a[j]){
				count++;
				swap(a[i],a[j]);
				vp.push_back(make_pair(i,j));
			}
		}
	}
	cout << vp.size() << endl;
	for(auto p:vp) cout << p.first << ' ' << p.second << endl;
	cin >> n;
}
0