結果

問題 No.397 NO MORE KADOMATSU
ユーザー newlife171128newlife171128
提出日時 2018-01-16 23:53:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 1,004 bytes
コンパイル時間 780 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 24,432 KB
平均クエリ数 936.56
最終ジャッジ日時 2023-09-24 01:38:13
合計ジャッジ時間 2,622 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,388 KB
testcase_01 AC 20 ms
24,396 KB
testcase_02 AC 19 ms
23,664 KB
testcase_03 AC 23 ms
24,432 KB
testcase_04 AC 24 ms
24,312 KB
testcase_05 AC 26 ms
24,048 KB
testcase_06 AC 28 ms
23,364 KB
testcase_07 AC 29 ms
23,388 KB
testcase_08 AC 21 ms
23,652 KB
testcase_09 AC 20 ms
23,676 KB
testcase_10 AC 41 ms
24,048 KB
testcase_11 AC 22 ms
24,024 KB
testcase_12 AC 26 ms
23,796 KB
testcase_13 AC 30 ms
24,312 KB
testcase_14 AC 32 ms
24,312 KB
testcase_15 AC 30 ms
24,036 KB
testcase_16 AC 21 ms
24,300 KB
testcase_17 AC 20 ms
23,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <utility>

typedef long long ll;


using namespace std;

int kadomatsu[101];

int main() {

	int m=0;
	cin>>m;

	for(int i=0; i<m;i++){
		int tmp=0;
		cin>>tmp;
		kadomatsu[i] = tmp;
	}

	bool judge = true;

	int a=0;



	vector<pair<int,int> > ans;

	while(judge){

		judge = false;

		for(int i=0; i<m-1; i++){
			if(kadomatsu[i] > kadomatsu[i+1]){
				int tmp = kadomatsu[i];
				kadomatsu[i] = kadomatsu[i+1];
				kadomatsu[i+1] = tmp;

				judge = true;
				a++;

				pair<int , int> p(i,i+1);

				ans.push_back(p);
			/*	cout<<i<<" "<<i+1<<endl;*/
			}
		}

	}
	if(a ==0){
		cout<<0<<endl;
	}else {
		cout<<ans.size()<<endl;
		for(int i=0; i<ans.size(); i++){

			cout<<ans[i].first<<" "<<ans[i].second<<endl;
		}
	}

	int b;
	cin>>b;


	return 0;
}
0