Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
17816 孤独摇滚!hts 【USACO】Out of Place(不合适)(USACO 2018) C++ 通过 0 MS 244 KB 410 2023-01-12 15:55:47

Tests(10/10):


#include <iostream> #include <cstdio> #include <algorithm> using namespace std; int main() { int n; cin >> n; int cows[100], sorted[100]; for (int i = 0; i < n; i++) { cin >> cows[i]; sorted[i] = cows[i]; } sort(sorted, sorted + n); int swaps = 0; for (int i = 0; i < n; i++) { if (cows[i] != sorted[i]) { swaps++; } } cout << swaps - 1 << endl; return 0; }


测评信息: