結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー | Yut176 |
提出日時 | 2016-07-15 23:36:09 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 981 bytes |
コンパイル時間 | 614 ms |
コンパイル使用メモリ | 68,572 KB |
実行使用メモリ | 25,464 KB |
平均クエリ数 | 936.56 |
最終ジャッジ日時 | 2024-07-17 00:08:05 |
合計ジャッジ時間 | 2,306 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#include <iostream> #include <stdio.h> #include <math.h> #include <vector> #include <algorithm> using namespace std; int main(){ int n; cin >> n; vector<int> a(n); vector<int> b(n); for(int i=0;i<n;i++){ cin >> a[i]; } b = a; // sort(b.begin(),b.end()); int temp; int cnt=0; for (int i = 0; i < n - 1; i++) { for (int j = n - 1; j > i; j--) { if (a[j - 1] > a[j]) { temp = a[j]; a[j] = a[j - 1]; a[j - 1]= temp; cnt++; // cout << j << " " << j-1 << endl; } } } cout << cnt << endl; for (int i = 0; i < n - 1; i++) { for (int j = n - 1; j > i; j--) { if (b[j - 1] > b[j]) { temp = b[j]; b[j] = b[j - 1]; b[j - 1]= temp; // cnt++; cout << j << " " << j-1 << endl; } } } int d; cin >> d; return 0; }