제출 #1128301

#제출 시각아이디문제언어결과실행 시간메모리
1128301aarpen버블 정렬 (OJUZ10_bubblesort)C++20
34 / 100
1095 ms1004 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int N, K; cin >> N; cin >> K; vector<int> seq; for(int i = 0; i < N; i++){ int temp; cin >> temp; seq.push_back(temp); } for (int pass = 0; pass < K; pass++) { bool swapped = false; for (int j = 0; j < N - pass - 1; j++) { if (seq[j] > seq[j + 1]) { swap(seq[j], seq[j + 1]); swapped = true; } } // If no elements were swapped, the array is sorted if (!swapped) break; } for(int ll = 0; ll < N; ll++){ cout << seq[ll] << " "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...