結果
問題 | No.1604 Swap Sort:ONE |
ユーザー | Akshay Neema |
提出日時 | 2021-07-16 21:45:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 645 bytes |
コンパイル時間 | 1,486 ms |
コンパイル使用メモリ | 167,084 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 08:46:27 |
合計ジャッジ時間 | 2,333 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define ll long long const int maxn = 2e5+5; #define _time_ 1.0 * clock() / CLOCKS_PER_SEC mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int t;t=1; while(t--){ ll n;cin>>n; ll a[n]; ll ans= 0 ; for(int i=0;i<n;i++)cin>>a[i]; for(int i=1;i<n;i++){ int j = i; while(j>0 && a[j]<a[j-1]){ swap(a[j] , a[j-1]); ans++; j--; } } cout<<ans<<"\n"; } }