Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
;(function () { var n = +readline(); if (n < 3) { print(-1); return; } var str = []; for (var i = 0; i < n; i++) { str.push(n-i); } print(str.join(' ')); }).call(this);
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if n<3: print(-1) else: s=[100,2]+[1]*(n-2) print(' '.join(map(str,s)))
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; import java.io.PrintWriter; import java.util.*; import static java.lang.Math.*; public class A151 { static Scanner in = new Scanner(System.in); static PrintWriter w = new PrintWriter(System.out, true); static int ni() { return in.nextInt(); } static String nl() { return in.nextLin...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class CF162A implements Runnable { StringTokenizer tokenizer; BufferedReader in; PrintWriter out; public static void main(String[] args) { ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n > 2) while (n) cout << n-- << " "; else cout << -1; return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n == 1 or n == 2: print(-1) else: A = [(i + 1) % n + 1 for i in range(n)] for i in range(n): if i == n - 1: print(A[i]) print() else: print(A[i], end = ' ')
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(raw_input()) if n==1 or n==2: print -1 else: print ' '.join(['3' for _ in range(n-1)]+['2'])
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; while (~scanf("%d", &n)) { if (n == 1 || n == 2) { printf("-1\n"); } else { for (int i = n; i >= 1; i--) { printf("%d ", i); } printf("\n"); } } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=input() if n<=2: print -1 else: for i in xrange(n): print n-i
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); if (n == 1 || n == 2) puts("-1"); else for (int i = n; i >= 1; i--) printf("%d ", i); return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(raw_input()) if n<=2: print -1 else: for i in range(n,0,-1): print i,
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
# -*- coding: utf-8 -*- __author__ = 'Step' n = int(raw_input()) if n < 3: print -1 else: while n: print n, n -= 1
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Arrays; import java.util.List; import java.util.Scanner; public class A { public static void main(String[] Args) { new A().solve(); } void solve() { int n = si(); if (n <= 2) { System.out.println("-1"); } else { for (int i = 1, j = ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; if (n <= 2) cout << "-1"; else for (i = n; i > 0; i--) cout << i << ' '; return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if(n<=2): print(-1) else: for x in range(n,0,-1): print(x,end=" ")
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import sys from itertools import imap inp = sys.stdin if 0: from StringIO import StringIO s1 = '''15''' inp = StringIO(s1) def read_ints(): return map(int, inp.readline().split(' ')) n, = read_ints() if n <= 2: print -1 else: print ' '.join(imap(str, xrange(n, 0, -1)))
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if(n==1 or n==2): print(-1) else: for i in range (n,0,-1): print(i,end=' ')
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1 || n == 2) cout << "-1" << endl; else for (int i = n; i >= 1; i--) { cout << i << " "; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOExc...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1 || n == 2) { cout << "-1"; } else { for (int i = n; i >= 1; i--) { cout << i << " "; } } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.*; import java.security.SecureRandom; import java.util.*; import java.math.*; import java.awt.geom.*; import static java.lang.Math.*; public class Solution implements Runnable { public void solve() throws Exception { int n = sc.nextInt(); if (n <= 2) { out.println(-1); return; ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, i, a[50]; cin >> n; if (n <= 2) cout << "-1\n"; else { for (i = 0; i < n; i++) { a[i] = n - i; } for (i = 0; i < n; i++) cout << a[i] << " "; cout << "\n"; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> int main() { int n; scanf("%d", &n); if (n <= 2) printf("-1\n"); else { printf("%d %d", n - 1, n); for (int i = 1; i <= n - 2; ++i) printf(" %d", i); printf("\n"); } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
inf = 1001 def merge(L, n1, R, n2): L.append(inf) R.append(inf) a = [] i = j = 0 while i < n1 or j < n2: if L[i] < R[j]: a.append(L[i]) i += 1 else: a.append(R[j]) j += 1 return a def msort(a, n): if n == 1: return a ...
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.*; public class sorting{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if(n<=2) System.out.println(-1); else { System.out.print("2 3 1"); for(int i = 0; i<n-3; i++) ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); if (n < 3) System.out.println(-1); else { for (int i = n; i >= 1; i--) System.out.print(i + " "); ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if(n==1 or n==2): print(-1) else: for i in range(n,0,-1): print(i,end=" ")
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 2; int main() { ios::sync_with_stdio(false); int n; cin >> n; if (n <= 2) cout << -1 << endl; else cout << "2 3 1"; for (int i = 4; i <= n; ++i) { cout << ' ' << i; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
def get_counter_example(n): if n <= 2: return -1 n -= 2 counter = ['5', '5'] for i in xrange(n): counter += ['1'] return ' '.join(counter) if __name__ == "__main__": inpt = raw_input() args = [int(el) for el in inpt.split(' ')] rtn = get_counter_example(*args) if t...
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long n; long long i; scanf("%I64d", &n); if (n == 1 || n == 2) { printf("-1\n"); } else { printf("%I64d %I64d ", n, n - 1); for (i = 1; i <= n - 2; i++) { printf("%I64d", i); if (i != n - 2) printf(" "); else...
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; while (scanf("%d", &n) != EOF) { if (n == 1 || n == 2) { printf("-1\n"); } else { int i; printf("%d", n); for (i = n - 1; i >= 1; i--) { printf(" %d", i); } printf("\n"); } } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if n<=2: print(-1) else: a=[i for i in range(n,0,-1)] print(*a)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; template <typename T> inline string tostring(T a) { ostringstream os(""); os << a; return os.str(); } template <typename T> inline long long tolong(T a) { long long res; istringstream os(a); os >> res; return res; } template <typename T> inline vector<int> par...
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if n==1 or n==2: print (-1) else: ans=[1]*n ans[0]=10 ans[1]=9 print (*ans)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.*; /** * * @author greggy */ public class BuggySorting { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); if (n <= 2) { System.out.println("-1"); } else { for (int i = 0; i < n; i++) { ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); if (n < 3) { printf("-1\n"); } else { for (int i = n; i > 0; i--) { printf("%d%c", i, i == 1 ? '\n' : ' '); } } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n == 1 or n == 2: print(-1) else: print(*range(n, 0, -1))
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(raw_input()) out = range(n,0,-1) if n==1 or n==2: print -1 else: for i in out: print i,
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> int main() { int n, i; scanf("%d", &n); if (n == 1 || n == 2) printf("-1"); else for (i = n; i > 0; i--) printf("%d ", i); return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int n; cin >> n; if (n <= 2) cout << -1 << endl; else { for (int i = n; i >= 1; i--) cout << i << " "; cout << endl; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; if (n == 1 || n == 2) { cout << -1; return 0; } for (i = n; i >= 1; i--) cout << i << " "; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if n<=2: print(-1) else: for i in range(n,0,-1): print(i,end=" ") print()
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import random n=int(raw_input()) count = 0 while count < 1000: a=[] b=[] d=[] for i in range(0,n): a.append(random.choice(range(1,100))) b.append(int(a[i])) d.append(int(a[i])) b.sort() #a1,a2,....an #a0,a1,....an-1 for i in range(1,n): for j in range(i,n): j-=...
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { if (n < 3) { cout << -1 << endl; } else { for (int i = n; i > 0; --i) { cout << i << " "; } cout << endl; } } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); if (n <= 2) printf("-1\n"); else { while (n >= 1) { printf("%d ", n); n--; } } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.*; public class CF0246A { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); if(n<=2) System.out.println("-1"); else { for(int i=n;i>0;i--){ if(i==1) System.out.println(i); else System.out.print(i+" "); } } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if n<3: print(-1) else: print(' '.join(map(str,range(n,0,-1))))
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n < 3: print(-1) else: print(' '.join(list(map(str, range(n, 0, -1)))))
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if(n == 1 or n== 2): print(-1) else: i = n while(i >= 1): print(i,end=" ") i -=1
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n > 2) { for (int i = n; i > 0; i--) cout << i << " "; cout << endl; } else cout << -1 << endl; return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(raw_input()) if n<3: print -1 else: while n: print n n=n-1
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; while (~scanf("%d", &n)) { if (n == 1 || n == 2) printf("-1\n"); else { for (int i = n; i >= 1; i--) printf("%d ", i); } } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if n<3:print('-1') else: k=[i for i in range(n,0,-1)] print(*k)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> void swap(int &i, int &j) { int tmp = i; i = j; j = tmp; } int main() { int n; scanf("%d", &n); if (n == 1 || n == 0 || n == 2) { printf("-1"); return 0; } for (int i = n; i > 0; i--) printf("%d ", i); return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.*; import java.io.*; import java.lang.*; import static java.lang.System.*; public class P246A{ static int[] arr; static int n; static void swap(int i, int j){ int tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; } static void sort(){ for(int i=0; i<n; i++){ for(int j=i; j<n; j++){ if((...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); if (n == 1 || n == 2) System.out.println(-1); else { System.out.print(n-1 + " "); System.out.print(n+" "...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; public class BuggySorting { public BuggySorting() { // TODO Auto-generated constructor stub } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int n=sc.nextInt(); if(n<=2){ System.out.pr...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class D { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n=scan.nextInt(); ArrayList<Integer> a= new ArrayList<Integer>(); if(n>2) { for(int i=1;i<=n;i++) { a.add(i)...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; public class buggySorting { public static void main(String[] args) { // TODO Auto-generated method stub int n; Scanner in=new Scanner(System.in); n=in.nextInt(); if(n<=2) System.out.println("-1"); else{ for(int i=n;i>=1;i--) System.out.println(i+" "); } } }
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) print(-1 if n < 3 else " ".join(map(str, [x for x in range(n, 0, -1)])))
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#!/usr/bin/env python from sys import stdin n = int(stdin.readline()) if n < 3: print(-1) else: print(' '.join(map(str, [2, 2] + [1] * (n-2))))
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
def unlucky(n): if n <= 2: return [-1] a = list() for i in range(n, -1, -1): a.append(i) return a[:-1] print(*unlucky(int(input())))
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.*; public class Main { public static void main(String args[])throws Exception { Scanner Sc=new Scanner(System.in); int n=Sc.nextInt(); if(n>2) { for(int i=n;i>=1;i--) System.out.print(i+" "); System.out.println(); } ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, numberofgirl; cin >> n; if (n <= 2) { cout << -1 << endl; } else { for (int g = n; g >= 1; g--) { cout << g; if (g < n + 1) cout << " "; } cout << endl; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; public class Code151A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] ar = new int[n]; if (n <= 2){ System.out.print(-1); } else for (i...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if(n<3): print(-1) else: a=list() for i in range(n-2): a.append(i+1) a.insert(0,n-1) a.insert(0,n) for i in a: print(i,end=' ')
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> int number, i; using namespace std; int main() { cin >> number; if (number > 2) { for (i = number; i > 0; i--) { cout << i << " "; } } else { cout << "-1"; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int i, j, n; scanf("%d", &n); if (n == 1 || n == 2) printf("-1\n"); else { for (i = n; i > 0; i--) { printf("%d ", i); } printf("\n"); } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.Scanner; /** * * @author gargon */ public class JavaApplication30 { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); if (n>2){ for (int i=n; i>0...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(raw_input()) if n<3: print -1 else: ans=range(n,0,-1) print ' '.join(map(str,ans))
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(raw_input()) if n > 2: print ' '.join([`k` for k in xrange(n, 0, -1)]) else: print -1
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
a=int(input()) if a==1 or a==2: print(-1) else: print(3,5,end=' ') for i in range(a-2): print(1,end=' ')
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()); print(*((-1,), range(n, 0, -1))[n > 2])
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; typedef long long LL; int n; int main() { ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n; if (n == 1 || n == 2) { cout << "-1" << "\n"; return 0; } for (int i = n; i >= 1; i--) { cout << i << " "; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=input() if n<=2: print -1 else: for i in range(n-1): print 2, print 1
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(raw_input()) if n<=2: print -1 else: for i in range(n,0,-1): print i
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n <= 2) cout << -1 << "\n"; else { for (int i = 0; i < n; i++) { cout << n - i << " "; } cout << endl; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n < 3) cout << -1; else for (int i = n; i > 0; --i) { cout << i << ' '; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1 || n == 2) { cout << "-1" << endl; } else { while (n > 0) { cout << n << " "; n--; } } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n<3: print ('-1') else: print ("2 3 1 ") q = 3 while q<n: print (str(q)+" ") q = q + 1
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n,a=input(),range(1,60) print [' '.join(map(str,a[n-1::-1])),-1][n<3]
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if n<3: print(-1) else: print(*range(n,0,-1))
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.*; import java.util.*; public class test1 { public static void main(String[] args) throws Exception { new test1().run(); } PrintWriter out = null; void run() throws Exception { Scanner in = new Scanner(System.in); out = new PrintWriter(System.out); ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, i, j, p, a[1000]; while (cin >> n) { if (n > 2) { for (i = n; i >= 1; i--) cout << i << " "; cout << endl; } else cout << -1 << endl; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n=int(input()) if n<3:print(-1) else: for i in range(n,0,-1):print(i)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; if (n < 3) cout << "-1"; else { for (i = 0; i < n - 1; i++) { cout << 60 - i << " "; } cout << 2 << endl; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; long long mod = 1000000000 + 7; int main() { ios::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); long long n; cin >> n; if (n < 3) { cout << -1; return 0; } for (int i = n; i >= 1; i--) { cout << i << " "; } return...
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main(void) { int i, j, k, T; cin >> T; if (T <= 2) cout << "-1\n"; else { for (i = 1; i < T; i++) cout << "2 "; cout << "1\n"; } }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; if (n <= 2) { cout << -1; return 0; } for (int i = 2; i <= n; ++i) { if (i != 2) cout << " "; cout << i; } cout << " " << 1; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n <= 2: print(-1) else: for i in range(n): print(n - i + 1, end = ' ')
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = input() if n <= 2: print -1 exit() for i in xrange(n, 0, -1): print i,
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; if (n == 1 || n == 2) cout << "-1"; else { for (i = n; i >= 1; i--) cout << i << ' '; cout << '\n'; } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#################################################### # -*- coding: utf-8 -*- import sys w = sys.stdout.write read = sys.stdin.readline reads = sys.stdin.read def r(f=None): if f: return map(f, read().split()) else: return read().split() def rs(t,f=None): result = [] result_append = re...
PYTHON
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.io.*; import java.util.*; public class A_R151 { BufferedReader in; PrintWriter out; StringTokenizer st; void solve() throws IOException { int n = nextInt(); if (n <= 2){ out.println(-1); return; } for (int i = 0; i < n; i++) out.print((n - i) + " "); } void run() throws IOException...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n <= 2) { cout << -1; } else { while (n--) { cout << n + 1 << " "; } } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if (n > 2): for i in range(2, n+1): print(i, end = " ") print(1) else: print(-1)
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
import java.util.ArrayList; import java.util.Scanner; /** * * @author Arif */ public class Problem9 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner scanner = new Scanner(System.in); ...
JAVA
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
#include <bits/stdc++.h> int main() { int n = 0; scanf("%d", &n); if (n == 1 || n == 2) printf("-1"); else { int a[n + 1]; int i = 0; for (i = 1; i <= n; i++) { printf("%d ", n + 2 - i); } } return 0; }
CPP
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = int(input()) if n==1 or n==2: print(-1) else: for i in range(n,0,-1): print(i,end=' ') print()
PYTHON3
246_A. Buggy Sorting
Little boy Valera studies an algorithm of sorting an integer array. After studying the theory, he went on to the practical tasks. As a result, he wrote a program that sorts an array of n integers a1, a2, ..., an in the non-decreasing order. The pseudocode of the program, written by Valera, is given below. The input of ...
2
7
n = input() if n>2: print ' '.join([str(i) for i in xrange(n,0,-1)]) else: print -1
PYTHON