結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー | tossy |
提出日時 | 2016-07-16 17:20:55 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 1,237 bytes |
コンパイル時間 | 796 ms |
コンパイル使用メモリ | 87,600 KB |
実行使用メモリ | 24,348 KB |
平均クエリ数 | 619.94 |
最終ジャッジ日時 | 2023-09-24 00:21:24 |
合計ジャッジ時間 | 2,520 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
24,324 KB |
testcase_01 | AC | 23 ms
23,364 KB |
testcase_02 | AC | 25 ms
23,340 KB |
testcase_03 | AC | 25 ms
23,460 KB |
testcase_04 | AC | 24 ms
24,000 KB |
testcase_05 | AC | 26 ms
23,688 KB |
testcase_06 | AC | 28 ms
23,460 KB |
testcase_07 | AC | 28 ms
23,688 KB |
testcase_08 | AC | 26 ms
24,348 KB |
testcase_09 | AC | 24 ms
23,484 KB |
testcase_10 | AC | 25 ms
24,108 KB |
testcase_11 | AC | 23 ms
24,276 KB |
testcase_12 | AC | 30 ms
23,604 KB |
testcase_13 | AC | 32 ms
23,364 KB |
testcase_14 | AC | 31 ms
23,580 KB |
testcase_15 | AC | 32 ms
24,048 KB |
testcase_16 | AC | 24 ms
23,988 KB |
testcase_17 | AC | 24 ms
23,364 KB |
ソースコード
#include <cstdio> #include <cstring> #include <string> #include <cmath> #include <cassert> #include <iostream> #include <algorithm> #include <stack> #include <queue> #include <vector> #include <set> #include <map> #include <bitset> using namespace std; #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define mp(a,b) make_pair(a,b) #define pb(a) push_back(a) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<x<<endl #define INF 1<<30 typedef pair<int, int> P; int main(){ int n; cin>>n; vector<int> a(n), b(n); rep(i,n){scanf("%d", &a[i]); b[i]=a[i];} vector<P> vec[2]; rep(i,n){ for(int j=0; j<n-1-i; j++){ if(a[j]<a[j+1]){ vec[0].pb(mp(j,j+1)); swap(a[j], a[j+1]); } } } rep(i,n){ for(int j=0; j<n-1-i; j++){ if(b[j]>b[j+1]){ vec[1].pb(mp(j,j+1)); swap(b[j], b[j+1]); } } } int idx; if(vec[0].size() < vec[1].size()) idx=0; else idx=1; cout<<vec[idx].size()<<endl; rep(i,vec[idx].size()) printf("%d %d\n", vec[idx][i].first, vec[idx][i].second); cin>>n; return 0; }