結果
| 問題 | No.366 ロボットソート |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-10 16:58:42 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 903 bytes |
| 記録 | |
| コンパイル時間 | 1,946 ms |
| コンパイル使用メモリ | 214,516 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-02-10 16:58:45 |
| 合計ジャッジ時間 | 3,384 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 WA * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int maxn = 1e5 + 1;
#define pii pair<int, int>
#define ll long long
#define pq priority_queue
#define se second
#define fi first
int n, k;
vector<int> a;
bool dasap(vector<int> &ans) {
for (int i = 0; i < ans.size()- 1; i++) {
if(a[i] > a[i + 1]) return false;
}
return true;
}
void solve() {
cin >> n;
a.resize(n);
for (int i = 0; i < n; i++) cin >> a[i];
cin >> k;
int ans = 0;
for (int it = 0; it <= 10000; it++) {
for (int i = 0; i < n - k; i++) {
if(a[i] > a[i + k]) {
swap(a[i], a[k + i]);
ans++;
}
}
}
if(!dasap(a)) cout << -1 << '\n';
else cout << ans << '\n';
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}