結果
| 問題 | No.366 ロボットソート |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-10 16:46:34 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 454 bytes |
| 記録 | |
| コンパイル時間 | 1,975 ms |
| コンパイル使用メモリ | 213,748 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-02-10 16:46:38 |
| 合計ジャッジ時間 | 2,926 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,m,cnt = 0;
cin >> n >> m;
vector<int> a(n);
for(int i=0;i<n;i++) cin >> a[i];
for(int i=0;i<n;i++){
for(int j=i;j<n;j = j + m){
if(a[i] > a[j]){
swap(a[i], a[j]);
cnt ++;
}
}
}
for(int i=0;i<n-1;i++)
if(a[i] > a[i+1]) cnt = -1;
cout << cnt;
}