diff --git a/problem/P1116/P1116.cpp b/problem/P1116/P1116.cpp new file mode 100644 index 00000000..024a11fd --- /dev/null +++ b/problem/P1116/P1116.cpp @@ -0,0 +1,25 @@ +// R38788162 + +#include + +using namespace std; + +int main() { + int n, a[10005], ans = 0; + cin >> n; + for (int i = 0; i < n; i++) { + cin >> a[i]; + } + for (int i = 0; i < n; i++) { + for (int j = 1; j < n; j++) { + if (a[j] < a[j - 1]) { + a[j] ^= a[j - 1]; + a[j - 1] ^= a[j]; + a[j] ^= a[j - 1]; + ans++; + } + } + } + cout << ans << endl; + return 0; +}