結果
問題 | No.1604 Swap Sort:ONE |
ユーザー | aut_jul_dur |
提出日時 | 2021-07-16 21:54:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 855 bytes |
コンパイル時間 | 3,064 ms |
コンパイル使用メモリ | 228,640 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 09:01:19 |
合計ジャッジ時間 | 4,198 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(),(x).end() const long long MOD = 1000000007; const long long INF = 9999999999999999; using ll = long long; using mint = modint1000000007; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } int main(){ ll N; cin>>N; vector<ll> A(N); rep(i,N){ cin>>A[i]; } ll ans = 0; rep(i,N){ if(A[i] == i+1){ continue; } else{ ll temp = A[i]; A[i] = i+1; for(int k = i+1;k<N;k++){ if(A[k]<temp && A[k]>=(i+1)){ A[k]++; ans++; } } } } cout << ans << endl; return 0; }