Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int N,K;
- scanf("%d%d",&N,&K);
- int A[N],B[N];
- for (int i=0; i<N; i++){
- cin >> A[i];
- if (A[i] % K < A[i+1] % K){
- swap(A[i],A[i+1]);
- }
- }
- for (int i=0; i<N; i++){
- cout << A[i] << " ";
- }
- }
Add Comment
Please, Sign In to add comment