id
int64 251M
307M
| language
stringclasses 12
values | verdict
stringclasses 290
values | source
stringlengths 0
62.5k
| problem_id
stringclasses 500
values | type
stringclasses 2
values |
---|---|---|---|---|---|
291,588,480 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while(t-->0){
int count = 0;
int n = scan.nextInt();
Set<Integer> set = new HashSet<>();
for(int i=0;i<n;i++){
int value = scan.nextInt();
if(set.contains(value)) count++;
else set.add(value);
}
System.out.println(n-1-count);
}
}
}
|
2031A
|
wrong_submission
|
291,599,782 |
Java 8
|
WRONG_ANSWER on test 2
|
import java.util.Scanner;
public class ModernMonument {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
while (t-- > 0) {
int n = scanner.nextInt();
int[] heights = new int[n];
for (int i = 0; i < n; i++) {
heights[i] = scanner.nextInt();
}
System.out.println(minOperations(heights));
}
}
private static int minOperations(int[] heights) {
int operations = 0;
int prevHeight = heights[0];
for (int i = 1; i < heights.length; i++) {
if (heights[i] < prevHeight) {
operations++;
prevHeight = heights[i];
} else {
prevHeight = Math.min(prevHeight, heights[i]);
}
}
return operations;
}
}
|
2031A
|
wrong_submission
|
291,816,624 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
int count = 0;
for (int i = 0; i < n-1; i++) {
if (arr[i + 1] < arr[i]) {
count++;
}
}
System.out.println(count);
}
sc.close();
}
}
|
2031A
|
wrong_submission
|
291,585,848 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int Mod=1000000007;
constexpr int inf=2e9;
void solve() {
int n;
cin>>n;
vector<int> h(n+2);
for(int i=1;i<=n;i++) {
cin>>h[i];
}
h[0]=0,h[n+1]=100;
int i=1,j=n;
while(i<=n && h[i]>=h[i-1]) {
i++;
}
while(j>=1 && h[j]<=h[j+1]) {
j--;
}
cout<<min(j,n+1-i)<<"\n";
}
int main() {
ios::sync_with_stdio(false),cin.tie(0);
int _=1;
cin>>_;
while(_--)
solve();
return 0;
}
|
2031A
|
wrong_submission
|
298,982,222 |
Java 8
|
WRONG_ANSWER on test 2
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
/*
AdiBhai0845R
AdiBhai0845R
AdiBhai0845R
AdiBhai0845R
*/
public class Codechef {
private int V;
private LinkedList<Integer>[] adj;
static final int top = 400005;
List<Integer> rank = new ArrayList<>();
List<Integer> parent = new ArrayList<>();
static final long INF = (long) 1e18;
static final int MOD = 1000000007;
public Codechef(int v) {
V = v;
adj = new LinkedList[v];
for (int i = 0; i < v; ++i)
adj[i] = new LinkedList<>();
}
public static void main(String[] args) throws IOException {
FastInput sc = new FastInput();
int t = sc.nextInt();
while (t-- > 0) {
functi1(sc);
}
sc.close();
}
static void functi1(FastInput sc) throws IOException {
int n = sc.nextInt();
int [] h = new int[n];
for(int i =0;i<n;i++){
h[i] = sc.nextInt();
}
int b [] = Arrays.copyOf(h, n);
int count =0;
int count1 =0;
for(int i =0;i<n-1;i++){
if(h[i]>h[i+1]){
count++;
h[i+1]=h[i];
}
}
for(int i=n-1;i>0;i--){
if(b[i]<b[i-1]){
count1++;
b[i-1] = b[i];
}
}
System.out.println(Math.min(count1,count));
}
public static BigInteger factorial(int n) {
if (n < 0) {
throw new IllegalArgumentException("Factorial is not defined for negative numbers.");
}
BigInteger answult = BigInteger.ONE;
for (int i = 2; i <= n; i++) {
answult = answult.multiply(BigInteger.valueOf(i));
}
return answult;
}
public static long upperBound1(long a[], int start, long end, long value) {
long low = start;
long high = end;
while (low < high) {
long mid = (low + high) / 2;
if (a[(int) mid] <= value) {
low = mid + 1;
} {
high = mid;
}
}
return low;
}
public static void sieve(int n) {
boolean[] isPrime = new boolean[n + 1];
for (int i = 0; i <= n; i++)
isPrime[i] = true;
for (int p = 2; p * p <= n; p++) {
if (isPrime[p]) {
for (int multiple = p * p; multiple <= n; multiple += p) {
isPrime[multiple] = false;
}
}
}
for (int i = 2; i <= n; i++) {
if (isPrime[i]) {
System.out.print(i + " ");
}
}
}
public static boolean isPowerOfTwo(int n) {
if (n <= 0) {
return false;
}
return (n & (n - 1)) == 0;
}
public static boolean isPrime(int n) {
if (n <= 1) {
return false;
}
if (n <= 3) {
return true;
}
if (n % 2 == 0 || n % 3 == 0) {
return false;
}
for (int i = 5; i * i <= n; i += 6) {
if (n % i == 0 || n % (i + 2) == 0) {
return false;
}
}
return true;
}
public static int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
public static int lcm(int x, int y) {
return (x / gcd(x, y)) * y;
}
public static void sort(int a[]) {
Arrays.sort(a);
}
private static long getSum(long n) {
return (n * (n + 1)) / 2;
}
public static int completeBinarySearch(int[] array, int target) {
int left = 0;
int right = array.length - 1;
while (left <= right) {
int mid = left + (right - left) / 2;
if (array[mid] == target) {
return mid;
}
if (array[mid] < target) {
left = mid + 1;
} {
right = mid - 1;
}
}
return -1;
}
public static HashMap<Integer, Integer> hashmap(int a[]) {
HashMap<Integer, Integer> h1 = new HashMap<>();
for (int i : a) {
h1.put(i, h1.getOrDefault(i, 0) + 1);
}
return h1;
}
void addEdge(int v, int w) {
adj[v].add(w);
}
private void DFSUtil(int v, boolean[] visited) {
visited[v] = true;
System.out.print(v + " ");
for (int n : adj[v]) {
if (!visited[n])
DFSUtil(n, visited);
}
}
public void DFS(int startVertex) {
boolean[] visited = new boolean[V];
DFSUtil(startVertex, visited);
}
public void BFS(int startVertex) {
boolean[] visited = new boolean[V];
LinkedList<Integer> counteue = new LinkedList<>();
visited[startVertex] = true;
counteue.add(startVertex);
while (!counteue.isEmpty()) {
startVertex = counteue.poll();
System.out.print(startVertex + " ");
for (int n : adj[startVertex]) {
if (!visited[n]) {
visited[n] = true;
counteue.add(n);
}
}
}
}
public static long lowerBound(long[] arr, long target) {
int low = 0, high = arr.length;
while (low < high) {
int mid = (low + high) / 2;
if (arr[mid] < target) {
low = mid + 1;
} {
high = mid;
}
}
return low;
}
public static long upperBound(Long[] arr, long target) {
int left = 0;
int right = arr.length;
long answult = -1;
while (left < right) {
int mid = left + (right - left) / 2;
if (arr[mid] <= target) {
answult = arr[mid];
left = mid + 1;
} {
right = mid;
}
}
return answult;
}
public static int binarySearch(int[] arr, int start, int end, int target) {
while (start <= end) {
int mid = start + (end - start) / 2;
if (arr[mid] == target) {
return mid;
}
if (arr[mid] < target) {
start = mid + 1;
} {
end = mid - 1;
}
}
return -1;
}
static class FastInput {
BufferedReader br;
StringTokenizer st;
public FastInput() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() throws IOException {
while (st == null || !st.hasMoreElements()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
int nextInt() throws IOException {
return Integer.parseInt(next());
}
long nextLong() throws IOException {
return Long.parseLong(next());
}
double nextDouble() throws IOException {
return Double.parseDouble(next());
}
String nextLine() throws IOException {
return br.readLine();
}
public void close() throws IOException {
br.close();
}
}
}
class DisjointSet {
List<Integer> rank = new ArrayList<>();
List<Integer> parent = new ArrayList<>();
List<Integer> size = new ArrayList<>();
public DisjointSet(int n) {
for (int i = 0; i <= n; i++) { // Initialize the lists
rank.add(0);
parent.add(i);
size.add(1);
}
}
public int findUPar(int node) {
if (node == parent.get(node)) {
return node;
}
int ulp = findUPar(parent.get(node));
parent.set(node, ulp);
return ulp;
}
public void unionByRank(int u, int v) {
int ulp_u = findUPar(u);
int ulp_v = findUPar(v);
if (ulp_u == ulp_v)
return;
if (rank.get(ulp_u) < rank.get(ulp_v)) {
parent.set(ulp_u, ulp_v);
} if (rank.get(ulp_v) < rank.get(ulp_u)) {
parent.set(ulp_v, ulp_u);
} {
parent.set(ulp_v, ulp_u);
rank.set(ulp_u, rank.get(ulp_u) + 1);
}
}
}
class Pair {
long x, y;
public Pair(int x, int y) {
this.x = x;
this.y = y;
}
public long getX() {
return x;
}
public long getY() {
return y;
}
}
class Pair3 {
int first, second, third;
public Pair3(int first, int second, int third) {
this.first = first;
this.second = second;
this.third = third;
}
}
|
2031A
|
wrong_submission
|
292,898,421 |
Java 8
|
WRONG_ANSWER on test 2
|
/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int max =0;
int n =sc.nextInt();
int[] arr = new int[n+1];
if(n==1){
System.out.println("0");
}else{
for(int i=0;i<n;i++){
int x = sc.nextInt();
arr[x]++;
}
for(int i=0;i<n;i++){
max = Math.max(max ,arr[i] );
}
System.out.println(n - max);
}
}
// System.out.println("Hello World");
}
}
|
2031A
|
wrong_submission
|
291,722,063 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
import java.util.Map.*;
import java.util.stream.*;
import java.util.function.*;
public class Run {
static void solve(Scanner in) {
var count = in.nextLong();
Stream<Long> heights = LongStream.generate(() -> in.nextLong())
.limit(count).boxed();
// Find a pivot point and flip everything else
// 1 2 3 4 5 --> 4
// 2 2 2 2 2 --> 0
// 2 2 3 4 5 --> 3
// 2 2 2 4 4 4 4 4 5 6 7 8 9 10 11
var map = heights.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
var max = map.entrySet().stream().max(Map.Entry.comparingByValue()).map(Entry::getKey);
System.out.println(max.map(m -> count - m).orElse(count));
}
public static void main(String[] args) {
var in = new Scanner(System.in);
var tc = in.nextLong();
while (tc-- > 0) {
solve(in);
}
in.close();
}
}
|
2031A
|
wrong_submission
|
291,597,655 |
Java 21
|
RUNTIME_ERROR on test 2
|
import java.util.*;
public class Ques1{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- >0){
int n = sc.nextInt();
int[] A= new int[n];
for(int i = 0; i<n; i++){
A[i] =sc.nextInt();
}
ArrayList<Integer> T = new ArrayList<Integer>();
int count = 1;
for(int i = 0;i<n-1;i++){
if(A[i]==A[i+1]){
count++;
}
else{
T.add(count);
count = 1;
}
}
Collections.sort(T);
int x = 1;
if(n>1){
x = T.get(T.size()-1);
}
System.out.println(n-x);
}
}
}
|
2031A
|
wrong_submission
|
291,883,818 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
signed main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> v(n);
for (int &x: v) cin >> x;
int cur = 1;
int ans = 1;
for (int i = 1;i < n;i++) {
if (v[i] == v[i - 1]) cur++;
else {
ans = max(ans, cur);
cur = 1;
}
}
cout << n - ans << '\n';
}
}
/*
*/
|
2031A
|
wrong_submission
|
291,599,090 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t; cin >> t;
while (t--){
int n; cin >> n;
set <int> s;
for (int i=0; i<n; i++){
int h; cin >> h;
s.insert(h);
}
int z = s.size();
cout << z-1 << endl;
}
}
|
2031A
|
wrong_submission
|
291,612,857 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int arr[n];
for(int i = 0;i<n;i++){
int v;
cin>>v;
arr[i] = v;
}
int i = 0, j = n-1;
while(j > 0 && arr[j] >= arr[j-1]){
j--;
}
int ans = j;
while(i < j && (i == 0 || arr[i] >= arr[i-1])){
while(j < n && arr[i] > arr[j]){
j++;
}
ans = min(ans, j-i-1);
i++;
}
cout<<ans<<endl;
}
}
|
2031A
|
wrong_submission
|
293,441,310 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
#define ll long long
const ll M = 1000000007;
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r" , stdin) ;
freopen("output.txt", "w" , stdout) ;
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t ;
cin >> t ;
while (t--) {
ll n ;
cin >> n;
vector<ll> v(n) ;
for (int i = 0 ; i < n ; i++) {
cin >> v[i] ;
}
vector<ll>v_copy = v ;
ll ct = 0 ;
for (int i = 1 ; i < n ; i++) {
if (v[i - 1] > v[i]) {
ct++ ;
v[i] = v[i - 1] ;
}
}
ll ct_copy = 0 ;
for (int i = n - 1 ; i >= 1 ; i--) {
if (v_copy[i - 1] > v_copy[i]) {
ct_copy++ ;
v_copy[i - 1] = v_copy[i] ;
}
}
ct = min(ct, ct_copy) ;
cout << ct << "\n" ;
}
return 0;
}
|
2031A
|
wrong_submission
|
291,697,611 |
C++23 (GCC 14-64, msys2)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
#define sz(x) int((x).size())
#define all(x) begin(x), end(x)
#define endl '\n'
using namespace std;
const int sz = 105;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--){
int n;
cin >> n;
int a[n];
for(int i = 0; i < n; i++){
cin >> a[i];
}int c = 0;
for(int i = 1; i < n; i++){
if(a[i]<a[i-1]){
c++;
}
}cout << c << endl;
}
return 0;
}
|
2031A
|
wrong_submission
|
291,612,812 |
Java 8
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class Penchick {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
sc.nextLine(); // Consume the newline character after the integer input
while (t-- > 0) {
int n = sc.nextInt();
sc.nextLine(); // Consume the newline character after the integer input
int h[] = new int[n];
String s = sc.nextLine();
String ns[] = s.split(" ");
for (int i = 0; i < n; i++) {
h[i] = Integer.parseInt(ns[i]);
}
Arrays.sort(h);
int c = 0;
int max = h[n - 1];
for (int i = 0; i < n; i++) {
if (max > h[i]) {
c++;
}
}
System.out.println(c);
}
sc.close();
}
}
|
2031A
|
wrong_submission
|
291,584,694 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
using namespace std;
using namespace __gnu_pbds;
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 2e5 + 3;
void solve()
{
int n;
cin >> n;
set<int> s;
for (int i = 0; i < n; ++i)
{
int x;
cin >> x;
s.insert(x);
}
cout << s.size() - 1 << endl;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
|
2031A
|
wrong_submission
|
291,597,109 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i)
{
cin >> a[i];
}
int c = 0;
for (int i = 1; i < n; ++i)
{
if (a[i] != a[i - 1])
{
++c;
}
}
cout << c << endl;
}
return 0;
}
|
2031A
|
wrong_submission
|
291,794,921 |
C++23 (GCC 14-64, msys2)
|
WRONG_ANSWER on test 2
|
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[100010];
void solve()
{
int n;
cin >>n;
for(int i=0;i<n;i++)
cin >>a[i];
int maxx=1;
int ant=1;
for(int i=0;i<n-1;i++)
{
if(a[i]==a[i+1])
{
ant++;
}
maxx=max(ant,maxx);
}
cout <<n-maxx<<endl;
}
signed main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int t;
cin >>t;
while(t--)
{
solve();
}
return 0;
}
|
2031A
|
wrong_submission
|
291,579,664 |
Java 8
|
WRONG_ANSWER on test 2
|
import java.io.*;
import java.util.*;
public class Main {
private static final FastIO sc = new FastIO();
public static void main(String[] args) {
int t = sc.nextInt();
while (t-- > 0) {
solve();
}
}
static void solve() {
int n=sc.nextInt();
int [] a=new int [n];
int i=0;
for(i=0;i<n;i++)
a[i]=sc.nextInt();
for(i=1;i<n;i++)
{
if(a[i]!=a[0])
{
System.out.println(n-i);
return;
}
}
System.out.println("0");
return;
}
static long cnt(long n)
{
if(n<=1)
return n;
if(n%2==1)
return 1+cnt(n/2);
return cnt(n/2);
}
static boolean check(long a[],long m,int n)
{
int i=0;
boolean bol=false;
for(i=0;i<n;i+=2)
{
if(i+1<n && a[i+1]-a[i]<=m)
{
continue;
}
else if(i+1<n)
{
if(bol)
return false;
bol=true;
i--;
}
}
return true;
}
}
class FastIO extends PrintWriter {
private BufferedReader br;
private StringTokenizer st;
public FastIO() {
this(System.in, System.out);
}
public FastIO(InputStream in, OutputStream out) {
super(out);
br = new BufferedReader(new InputStreamReader(in));
}
public String next() {
try {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
}
|
2031A
|
wrong_submission
|
292,760,559 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
int main()
{
SYNC
int t;
cin >> t;
while(t--)
{
int n;
cin >> n;
vector<int> vec(n);
for(int i = 0; i < n; i ++)
{
cin >> vec[i];
}
sort(all(vec));
int res = 0;
for(int i = 1; i < n; i ++)
{
if(vec[i] != vec[i - 1])
res++;
}
cout << res << '\n';
}
return 0;
}
|
2031A
|
wrong_submission
|
296,796,796 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int Fact[10000002];
int ar[10000002];
#define mod 998244353
vector<vector<int>>adj;
void dfs(int n,int par)
{
for(auto x: adj[n])
{
if(x!=par)
{
dfs(x,n);
cout<<x<<' ';
}
}
}
int32_t main()
{
int tt;
cin>>tt;
while(tt--)
{
int n;
cin>>n;
int ar[n+2];
for(int i=1;i<=n;i++) cin>>ar[i];
if(n==1)
{
cout<<0<<endl;
continue;
}
int ans =0;
for(int i=2;i<=n;i++)
{
if(ar[i]<ar[i-1]) ans++;
}
cout<<ans<<endl;
}
return 0;
}
|
2031A
|
wrong_submission
|
291,650,754 |
Python 3
|
WRONG_ANSWER on test 2
|
a=int(input())
for i in range(a):
b=int(input())
c=list(map(int,input().split()))
if c==(sorted(c))[::-1]:
d=len(set(c))
if d==len(c):
print(len(c)-1)
else:
print(len(c)-d)
else:
print(0)
|
2031A
|
wrong_submission
|
291,624,996 |
Java 8
|
WRONG_ANSWER on test 2
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0) {
int n = sc.nextInt();
int arr[] = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
int cnt = 0;
for (int i = 0; i <n-1; i++) {
if (arr[i] >arr[i + 1]) {
cnt++;
}
}
System.out.println(cnt);
}
}
}
|
2031A
|
wrong_submission
|
291,601,528 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class Height {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int[] height = new int[n];
for (int i = 0; i < height.length; i++) {
height[i] = sc.nextInt();
}
int operation = 0;
for (int i = 1; i < height.length; i++) {
if(height[i] < height[i - 1]){
operation +=1;
height[i] = height[i - 1];
}
}
System.out.println(operation);
}
}
}
|
2031A
|
wrong_submission
|
291,611,515 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while(t--){
int n;
cin >> n;
vector<int> v(n);
for(int &h1 : v){
cin >> h1;
}
int ans=INT_MAX;
int count=0;
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
if(v[j]!=v[i])count++;
}ans=min(ans,count);
}
cout<<ans<<endl;
}
}
|
2031A
|
wrong_submission
|
296,419,107 |
Python 3
|
WRONG_ANSWER on test 2
|
t = int(input())
for _ in range(t):
n = int(input())
lst = list(map(int, input().split()))
count = 0
for i in range(n - 1):
if lst[i] > lst[i + 1]:
count += 1
print(count)
|
2031A
|
wrong_submission
|
291,644,011 |
Python 3
|
WRONG_ANSWER on test 2
|
a=int(input())
for i in range(a):
b=int(input())
c=list(map(int,input().split()))
d=0
for e in range(1,b):
if c[e]<c[e-1]:
d+=1
print(d)
|
2031A
|
wrong_submission
|
291,652,508 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int tt = 0;
while(tt<t){
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
int l = 0;
int r = n-1;
int c = 0;
if(n==1){
System.out.println(0);
}else{
while(l<r){
int mid = (r+l)/2;
if(arr[l]>arr[mid] && arr[r]<arr[mid]){
l++;
r--;
c=c+2;
}
else if(arr[l]<=arr[mid]){
l=mid+1;
c++;
r--;
}
else{
r = mid-1;
c++;
r++;
}
}
System.out.println(c);
}
tt++;
}
}
}
|
2031A
|
wrong_submission
|
293,648,103 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.Scanner;
public class A2031 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int w=0;w<t;w++){
int n = sc.nextInt();
int[] arr = new int[n];
for(int i=0;i<n;i++){
arr[i] = sc.nextInt();
}
int maxi = arr[0];
int cnt = 0;
for(int i=0;i<n;i++){
if(arr[i] == maxi){
cnt++;
}else{
break;
}
}
System.out.println(n-cnt);
}
}
}
|
2031A
|
wrong_submission
|
296,094,336 |
Python 3
|
WRONG_ANSWER on test 2
|
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n):
if a[i] < a[i-1]:
ans += 1
print(ans)
|
2031A
|
wrong_submission
|
291,616,499 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.Scanner;
public class force2 {
public static void main(String args[]) {
Scanner SC = new Scanner(System.in);
int t = SC.nextInt();
while (t-- > 0)
{
int n=SC.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++)
arr[i] = SC.nextInt();
int c=0;
for (int i = 0; i < n-1; i++)
{
if(arr[i]==arr[i+1])
c++;
}
System.out.println(n-1-c);
}
}
}
|
2031A
|
wrong_submission
|
293,929,166 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
import java.io.*;
import java.math.*;
public class sub {
/*
* /\_/\ (= ._.) / > \>
*/
static int mod = 998244353;
public static void main(String args[]) {
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int a[] = new int[n];
for(int i = 0;i<n;i++)a[i]=sc.nextInt();
int ans = 0;
for(int i = 0;i<n-1;i++) {
if(a[i]>a[i+1]) {
ans++;
a[i+1]=a[i];
}
}
out.println(ans);
}
out.close();
}
/*
* public static long bincoef(int n, int k) { if(n < k) return 0L; return (p[n]
* * pow((p[n - k] * p[k]) % mod, mod - 2,mod))%mod; }
*/
static long pow(long a, long b, long mod) {
if (b == 0) {
return 1L;
}
long val = pow(a, b / 2, mod);
if (b % 2 == 0) {
return val * val % mod;
}
return val * val % mod * a % mod;
}
static int gcd(int a, int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
static int lcm(int a, int b) {
return a * b / gcd(a, b);
}
static Kattio sc = new Kattio();
static PrintWriter out = new PrintWriter(System.out);
static class Kattio {
static BufferedReader r;
static StringTokenizer st;
public Kattio() {
r = new BufferedReader(new InputStreamReader(System.in));
}
public String next() {
try {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(r.readLine());
}
return st.nextToken();
} catch (Exception e) {
return null;
}
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
}
}
|
2031A
|
wrong_submission
|
291,581,922 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
/*
Author : kmv a.k.a kzhi
K41 IT CHV
*/
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define ll long long
#define FOR(i,a,b) for (int i = a ; i <= b; ++ i)
#define FOD(i,a,b) for (int i = a; i >= b; -- i)
#define BIT(mask,i) ((mask >> i) & 1)
#define MASK(i) (1ll << (i))
#define OFFBIT(mask,i) (mask &~(1ll<<(i)))
#define ONBIT(mask,i) (mask | (1ll << (i)))
#define lg2(x) (63 - __builtin_clzll(x))
#define c_bit __builtin_popcountll
#define vi vector < int >
#define all(a) a.begin(), a.end()
#define pb push_back
#define ii pair<int,int>
#define fi first
#define se second
#define openfile(TASK) if (fopen(TASK".inp","r"))\
{freopen(TASK".inp","r",stdin);freopen(TASK".out","w",stdout);}
#define endl '\n'
#define Faster ios_base::sync_with_stdio(false); \
cin.tie(0); cout.tie(0);
#define mid(l,r) ((l + r) >> 1)
#define left(id) (id << 1)
#define right(id) ((id << 1) | 1)
#define ci const int
template <class X, class Y> bool maximize(X &a, const Y &b){if(a < b) return a = b, true;return false;}
template <class X, class Y> bool minimize(X &a, const Y &b){if(a > b) return a = b, true;return false;}
const int N = 55;
int n, a[N];
void SOLVE(){
cin >> n;
FOR (i, 1, n)
cin >> a[i];
int cnt = 0;
FOR (i, 2, n)
if (a[i] < a[i - 1]){
a[i] = a[i - 1];
cnt ++;
}
cout << cnt << endl;
}
signed main(){
Faster
openfile("test")
int q = 1;
cin >> q;
while (q --){
SOLVE();
}
return 0;
}
|
2031A
|
wrong_submission
|
291,641,317 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class monument {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
while(t>0)
{
int n=sc.nextInt();
int A[]=new int[n];
for(int i=0;i<n;i++)
{
A[i]=sc.nextInt();
}
Arrays.sort(A);
int count=0;
for(int i=0;i<n-1;i++)
{
if(A[i]<A[i+1])
count++;
}
System.out.println(count);
t--;
}
}
}
|
2031A
|
wrong_submission
|
291,624,407 |
Python 3
|
WRONG_ANSWER on test 2
|
def min_operations_to_non_decreasing(n, heights):
operations = 0
max_height = heights[0]
# Iterate through array starting from second element
for i in range(1, n):
# If current height is less than previous maximum
# We need to increase it to at least max_height
if heights[i] < max_height:
operations += 1
else:
# Update max_height if current height is larger
max_height = heights[i]
return operations
# Read number of test cases
t = int(input())
for _ in range(t):
# Read number of pillars
n = int(input())
# Read heights array
heights = list(map(int, input().split()))
# Print minimum operations needed
print(min_operations_to_non_decreasing(n, heights))
|
2031A
|
wrong_submission
|
291,653,494 |
Python 3
|
WRONG_ANSWER on test 2
|
t=int(input())
while t>0:
t-=1
n=int(input())
li=list(map(int,input().split(" ")))
s=set(li)
print(len(s)-1)
|
2031A
|
wrong_submission
|
293,298,608 |
Python 3
|
WRONG_ANSWER on test 2
|
t = int(input())
for x in range(t):
n = int(input())
arr = list(map(int,input().split()))
num = len(set(arr));
print(num-1)
|
2031A
|
wrong_submission
|
302,913,963 |
Python 3
|
WRONG_ANSWER on test 2
|
def solve():
n=int(input())
h=list(map(int,input().split()))
i=0
count=0
for x in h:
if x != h[n-1] and h[i] > h[i+1]:
count+=1
i+=1
print(count)
for testcase in range(int(input())):
solve()
|
2031A
|
wrong_submission
|
292,406,807 |
Python 3
|
WRONG_ANSWER on test 2
|
t = int(input())
for _ in range(t):
n, h = int(input()), (int(i) for i in input().split())
res, prv = 0, next(h)
for i in h:
res += i < prv
prv = max(i, prv)
print(res)
|
2031A
|
wrong_submission
|
292,859,037 |
Python 3
|
WRONG_ANSWER on test 2
|
def func(a):
m = 0
b = [1] * len(a)
for i in range(len(a) - 1):
if a[0] == a[len(a) - 1]:
b[i] = len(a)
break
if a[i] != a[i + 1]:
b[i] = (i + 1) - m
m = i + 1
print(len(a) - max(b))
t = int(input())
for i in range(t):
n = int(input())
a = list(input().split())
for j in range(n):
a[j] = int(a[j])
func(a)
|
2031A
|
wrong_submission
|
294,672,296 |
Python 3
|
WRONG_ANSWER on test 2
|
t = int(input())
for _ in range(t):
n = int(input())
h = list(map(int, input().split()))
count = 0
for i in range(n - 1):
if h[i] > h[i + 1]:
count += 1
print(count)
|
2031A
|
wrong_submission
|
291,625,173 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
for (int j = 0; j < t; j++) {
int n = scanner.nextInt();
int[] h = new int[n];
for (int i = 0; i < n; i++)
{
h[i] = scanner.nextInt();
}
int operations = 0;
for (int i = 1; i < n; i++)
{
if (h[i] < h[i - 1])
{
operations++;
h[i] = h[i - 1];
}
}
System.out.println(operations);
}
scanner.close();
}
}
|
2031A
|
wrong_submission
|
292,435,140 |
C++23 (GCC 14-64, msys2)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main() {
int t;
cin>>t;
while(t--){
int n;
cin>>n;
vector <int> vec;
for (int i=0; i<n; i++){
int x=0;
cin>>x;
vec.push_back(x);
}
sort(vec.begin(), vec.end());
vector <int> vec1(vec[n-1],0);
for (int i=0; i<n; i++){
vec1[vec[i]-1]++;
}
sort(vec1.begin(), vec1.end());
int count=0;
for (int i=0; i<vec1.size(); i++){
if (vec1[vec1.size()-1]==1){
count=1;
break;
}
if (vec1[i]==vec1[vec1.size()-1] && vec1[vec1.size()-1]!=1){
count+=vec1[i];
}
}
if (n==1){
cout<<0<<endl;
}
else{
cout<<vec.size()-count<<endl;
}
}
}
|
2031A
|
wrong_submission
|
291,599,477 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int testcases = scanner.nextInt();
for(int j=0;j<testcases;j++)
{
int bilnumber = scanner.nextInt();
int[] h = new int[bilnumber]; // the heights of the monuments pilliars
int first =0;
int count =0;
for(int i=0;i<h.length;i++)
{
h[i] = scanner.nextInt();
if(h[i] < first)
{
count++;
}
first = h[i];
}
System.out.println(count);
count =0;
}
}
}
|
2031A
|
wrong_submission
|
291,888,308 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class Main {
public static Scanner sc=new Scanner(System.in);
public static void solve() {
int n=sc.nextInt();
int[] arr=new int[n];
for(int i=0;i<n;i++) arr[i]=sc.nextInt();
int count=0;
for(int i=1;i<n;i++) {
if(arr[i]==arr[i-1]) continue;
arr[i]=arr[i-1];
count++;
}
System.out.println(count);
}
public static void main(String[] args) {
int t=sc.nextInt();
while(t--!=0) solve();
}
}
|
2031A
|
wrong_submission
|
305,005,632 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin>>n;
int ans=0;
int prev;
cin>>prev;
for(int i=1;i<n;i++){
int x;
cin>>x;
if(prev>x){
ans++;
prev=x;
}
}
cout<<ans<<endl;
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
}
|
2031A
|
wrong_submission
|
291,628,858 |
Python 3
|
WRONG_ANSWER on test 2
|
import math
tests = int(input())
for _ in range(tests):
pillar_length = int(input())
pillars = input()
numbers = list(map(int, pillars.split()))
if pillar_length == 1:
print(0)
continue
count = 0
max_height = numbers[0]
for i in range(1, pillar_length):
if numbers[i] >= max_height:
count += 1
max_height = numbers[i]
print(pillar_length - count - 1)
|
2031A
|
wrong_submission
|
295,352,761 |
Python 3
|
WRONG_ANSWER on test 2
|
n=int(input())
while n>0:
x=int(input())
y=list(map(int,input().split()))
i=0
for m in range(1,x):
if y[m]<y[m-1]:
if m+1<x and y[m]==y[m+1]:
y[m-1]=y[m]
y[m]=y[m-1]
i+=1
print(i)
n-=1
|
2031A
|
wrong_submission
|
291,671,742 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200010;
int T,n;
ll a[N];
void solve() {
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
if(n==1)
{
cout<<0<<endl;
return;
}
int ans=0;
for(int i=1;i<=n-1;i++)
{
if(a[i]>a[i+1])ans++;
}cout<<ans<<endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>T;
while(T--){
solve();
}return 0;
}
|
2031A
|
wrong_submission
|
291,583,959 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
int n;
cin >> n;
vector<int>a(n+1);
for(int i = 1;i<=n;i++) cin >> a[i];
int ans = 0;
for(int i = 2;i<=n;i++) if(a[i]<a[i-1]) ans++;
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while(t--) solve();
return 0;
}
|
2031A
|
wrong_submission
|
291,595,786 |
Python 3
|
WRONG_ANSWER on test 2
|
from math import *
def ar(): return list(map(int,input().split()))
for _ in range(int(input())):
n=int(input())
a=ar()
cnt=0
for i in range(1,n):
if(a[i]<a[i-1]):
cnt+=1
print(cnt)
|
2031A
|
wrong_submission
|
291,609,313 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int tt = sc.nextInt();
while (tt-- > 0) {
int n = sc.nextInt();
int height[] = new int[n];
for (int i = 0; i < n; i++) {
height[i] = sc.nextInt();
}
int count = 0;
for (int i = 0; i < height.length - 1; i++) {
if (height[i] > height[i + 1]) {
count++;
height[i] = height[i + 1];
}
}
System.out.println(count);
}
}
}
|
2031A
|
wrong_submission
|
291,585,632 |
Python 3
|
WRONG_ANSWER on test 2
|
t=int(input())
for i in range(t):
n,count=int(input()),0
h=list(map(int,input().split()))
for i in h:
if i<max(h):
count+=1
print(count)
|
2031A
|
wrong_submission
|
291,597,477 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.Scanner;
public class penchickandmodernmonument {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t!=0){
t--;
int n = sc.nextInt();
int[] arr = new int[n];
arr[0] = sc.nextInt();
int prev = arr[0];
if(n==1){
System.out.println(0);
continue;
}
int ans = 0;
for(int i=1; i<n; i++) {
arr[i] = sc.nextInt();
if(arr[i] == prev)
ans++;
}
System.out.println(n-ans-1);
}
}
}
|
2031A
|
wrong_submission
|
291,599,921 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class Main {
public static int minOperations(int[] h) {
int n = h.length;
int minIdx = 0;
for (int i = 1; i < n; i++) {
if (h[i] < h[minIdx]) {
minIdx = i;
}
}
int operations = 0;
for (int i = 1; i < n; i++) {
operations += Math.max(0, h[i-1] - h[i]);
}
return operations;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n = sc.nextInt();
int a[] = new int[n];
for(int i = 0;i<n;i++){
a[i] = sc.nextInt();
}
int res = minOperations(a);
System.out.println(res);
}
}
}
|
2031A
|
wrong_submission
|
291,609,308 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.Scanner;
public class aaContest {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int T=sc.nextInt();
while(T>0){
int operation=0;
int n=sc.nextInt();
int h[]=new int[n];
if(n==1){
System.out.println(0);
break;
}
for(int i=0;i<n;i++){
h[i]=sc.nextInt();
}
for(int i=0;i<n-1;i++){
if(h[i]>h[i+1]){
operation=operation+1;
}
}
System.out.println(operation);
T--;
}
}
}
|
2031A
|
wrong_submission
|
291,604,402 |
Python 2
|
WRONG_ANSWER on test 2
|
t = int(raw_input())
for _ in range(t):
n = int(raw_input())
h = map(int, raw_input().split())
operations = 0
max_height = h[-1]
for i in range(n - 2, -1, -1):
if h[i] > max_height:
operations += 1
max_height += 1
else:
max_height = h[i]
print operations
|
2031A
|
wrong_submission
|
291,588,925 |
Python 3
|
WRONG_ANSWER on test 2
|
T = int(input())
for _ in range(T):
count = 0
n = int(input())
h = list(map(int,input().split()))
for i in range(1,n):
if h[i-1]>h[i]:
count+=1
print(count)
|
2031A
|
wrong_submission
|
291,579,182 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.io.*;
import java.util.*;
import java.util.function.Function;
//params19
public class A_Penchick_and_Modern_Monument {
static final double PI = 3.141592653589;
static final int M = 1000000007;
static class Pair<U, V> {
public U first;
public V second;
public Pair(U first, V second) {
this.first = first;
this.second = second;
}
}
// acheive ceil value : ans+=(cnt+k-1)/k;
static class Utils {
// Prime
static boolean isPrime(int n) {
if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i += 6) {
if (n % i == 0 || n % (i + 2) == 0) return false;
}
return true;
}
// next prime after n
static int nextPrime(int n) {
n++;
while (!isPrime(n)) {
n++;
}
return n;
}
// Method to get all divisors of a given number n
static List<Integer> getDivisors(int n) {
List<Integer> divisors = new ArrayList<>();
// Loop from 1 to sqrt(n)
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
divisors.add(i);
if (i != n / i) {
divisors.add(n / i);
}
}
}
divisors.sort(Integer::compareTo);
return divisors;
}
// Prime Factorization - O(sqrt(n)) - return List of prime factors
static List<Integer> primeFactors(int n) {
List<Integer> ans = new ArrayList<>();
for (int i = 2; i * i <= n; i++) {
while (n % i == 0) {
ans.add(i);
n /= i;
}
}
if (n > 1) {
ans.add(n);
}
return ans;
}
// GCD - Euclidean Algorithm
static int gcd(int a, int b) {
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
// LCM
static int lcm(int a, int b) {
return (a / gcd(a, b)) * b;
}
// Sieve - prime number till n
static List<Integer> sieve(int n) {
boolean[] isPrime = new boolean[n + 1];
Arrays.fill(isPrime, true);
isPrime[0] = isPrime[1] = false;
for (int i = 2; i * i <= n; i++) {
if (isPrime[i]) {
for (int j = i * i; j <= n; j += i) {
isPrime[j] = false;
}
}
}
List<Integer> primes = new ArrayList<>();
for (int i = 2; i <= n; i++) {
if (isPrime[i]) {
primes.add(i);
}
}
return primes;
}
// Fast Power a ^ b % M
static long helper_a_power_b_mod(int a, int b) {
if (b == 0) return 1;
long temp = helper_a_power_b_mod(a, b / 2);
temp %= M;
temp *= temp;
temp %= M;
if ((b & 1) == 1) {
temp *= a;
temp %= M;
}
return temp;
}
// Modular Addition (a + b) % M
static long modularAddition(long a, long b, long M) {
return ((a % M) + (b % M)) % M;
}
// Modular Subtraction (a - b) % M
static long modularSubtraction(long a, long b, long M) {
return ((a % M) - (b % M) + M) % M;
}
// Modular Multiplication (a * b) % M
static long modularMultiplication(long a, long b, long M) {
return ((a % M) * (b % M)) % M;
}
// Modular Division (a / b) % M
static long modularDivision(long a, long b, long M) {
long bInverse = (long) Math.pow(b, M - 2) % M;
return (a % M) * bInverse % M;
}
}
static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreTokens()) {
try {
String line = br.readLine();
if (line == null) {
return null;
}
st = new StringTokenizer(line);
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
String token = next();
if (token == null) throw new NoSuchElementException("No more tokens available");
return Integer.parseInt(token);
}
long nextLong() {
String token = next();
if (token == null) throw new NoSuchElementException("No more tokens available");
return Long.parseLong(token);
}
double nextDouble() {
String token = next();
if (token == null) throw new NoSuchElementException("No more tokens available");
return Double.parseDouble(token);
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
<T> List<T> nextList(int n, Function<String, T> mapper) {
List<T> list = new ArrayList<>();
for (int i = 0; i < n; i++) {
String token = next();
if (token == null) throw new NoSuchElementException("No more tokens available");
list.add(mapper.apply(token));
}
return list;
}
}
private static int [] input_array(int n, FastScanner sc)
{
int arr[]=new int[n];
for(int i=0;i<n;i++)
{
arr[i]=sc.nextInt();
}
return arr;
}
public static void solve(FastScanner sc) {
//Utils.print(Utils.isPrime(x)); Prime
//Utils.print(Utils.gcd(x1, y1)); GCD
//Utils.print(Utils.lcm(x2, y2)); LCM
//Utils.print(Utils.sieve(y)); sieve
//Utils.print(Utils.primeFactors(x3)); Prime Factorization
//Utils.print(Utils.nextPrime(x4)); next prime after n
// Arrays.sort(arr, (a, b) -> Integer.compare(a[0], b[0])); -> sort 2D array based on 1st index
int n=sc.nextInt();
int arr[]=input_array(n,sc);
int cnt=0;
for(int i=0;i<n-1;i++)
{
if(arr[i]!=arr[i+1])
cnt++;
}
System.out.println(cnt);
}
public static void main(String[] args) {
FastScanner sc = new FastScanner();
int t = sc.nextInt();
while (t-- > 0) {
solve(sc);
}
}
}
|
2031A
|
wrong_submission
|
291,586,345 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class A_Penchick_and_Modern_Monument {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t = input.nextInt();
while(t-- > 0){
int n = input.nextInt();
int[] arr = new int[n];
for (int i = 0; i < arr.length; i++) {
arr[i] = input.nextInt();
}
int cnt = 0;
for (int i = 0; i < arr.length-1; i++) {
if(arr[i] > arr[i+1]){
cnt++;
arr[i] = arr[i+1];
}
}
System.out.println(cnt);
}
}
}
|
2031A
|
wrong_submission
|
301,610,342 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
private static final int mod = (int) 1e9 + 7; // mod
private static final int iif = 998244353; // int infinity!
public static void main(String[] args) {
try {
FastReader in = new FastReader();
FastWriter out = new FastWriter();
int testcases = 1;
testcases = in.nextInt();
//<------------------------ Main Code starts Here --------------------------------------------->
while (testcases-- > 0) {
int siz = in.nextInt();
Set<Integer> set = new HashSet<>();
for(int i = 0; i < siz; i++) {
set.add(in.nextInt());
}
out.println(set.size()-1);
}
out.close();
} catch (Exception e) {
e.printStackTrace();
return;
}
}
private static boolean check(Long[] nums,long mid,long curr) {
for(long num : nums) {
if(num <= mid) continue;
curr -= num;
}
return curr > 0;
}
//<-------------------------------------- Fast reader ----------------------------------------->
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (Exception e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine().trim();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
public Integer[] nextIntArray(int start, int end) {
Integer[] nums = new Integer[end];
for (int i = start; i < end; i++) {
nums[i] = Integer.parseInt(next());
}
return nums;
}
public Pair[] nextPairArray(int start, int siz) {
Pair[] nums = new Pair[siz];
for (int i = start; i < siz; i++) {
int v1 = Integer.parseInt(next());
int v2 = Integer.parseInt(next());
nums[i] = new Pair(v1, v2);
}
return nums;
}
public Long[] nextLongArray(int start, int siz) {
Long[] nums = new Long[siz];
for (int i = start; i < siz; i++) {
nums[i] = Long.parseLong(next());
}
return nums;
}
}
//<--------------------------------------- Fast writer ----------------------------------------->
static class FastWriter {
private final BufferedWriter bw;
public FastWriter() {
this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
}
public void print(Object object) throws IOException {
bw.append("" + object);
}
public void println() throws IOException {
bw.append("\n");
}
public void println(Object object) throws IOException {
print(object);
bw.append("\n");
}
public void close() throws IOException {
bw.close();
}
}
//<-------------------------------------------- Some helper methods ---------------------------------------->
private static long kadane(int l, int r, int[] nums) {
long sum = 0;
long mSum = 0;
for (int i = l; i < r; i++) {
if (sum < 0) sum = nums[i];
else sum += nums[i];
mSum = max(sum, mSum);
}
return mSum;
}
public static List<Integer> reversed(List<Integer> lis) {
List<Integer> ans = new ArrayList<>();
for (int i = lis.size() - 1; i >= 0; i--) {
ans.add(lis.get(i));
}
return ans;
}
public static void print(boolean cond, FastWriter out) throws IOException {
out.println(cond ? "YES" : "NO");
}
public static long fastPow(long b, long e) {
long res = 1;
while (e > 0) {
if (odd(e)) res = (res * b) % mod;
b = (b * b) % mod;
e = e >> 1;
}
return res;
}
public static int charToInt(char c) {
return (c - '0');
}
public static char intToChar(int n) {
return (char) (n + 48);
}
public static int[] sieve(int upto) {
int[] primes = new int[upto + 1];
Arrays.fill(primes, 1);
for (int i = 2; i * i <= upto; i++) {
if (primes[i] == 1)
for (int j = i * i; j <= upto; j += i) {
primes[j] = 0;
}
}
return primes;
}
private static long fact(int num) {
long v = 1;
for (int i = 1; i <= num; i++) {
v = (v * i) % mod;
}
return v;
}
private static long gcd(long a, long b) {
if (b != 0) return gcd(b, (a % b));
return a;
}
private static int gcd(int a, int b) {
if (b != 0) return gcd(b, (a % b));
return a;
}
private static long getSum(int startNum, int commonDiff, long range) {
long lastNum = startNum + (range - 1) * commonDiff;
return range * (startNum + lastNum) / 2;
}
private static boolean odd(long siz) {
return (siz & 1) == 1;
}
private static boolean powOf2(long siz) {
return (siz & (siz - 1)) == 0;
}
private static List<Integer> primeFactors(int siz) {
List<Integer> sizs = new ArrayList<>();
int[] p;
p = sieve(siz);
for (int i = 2; i <= siz; i++) {
while (siz % i == 0 && p[i] == 1) {
sizs.add(i);
siz /= i;
}
}
return sizs;
}
}
class Pair2 {
long v1;
long v2;
public Pair2(long v1, long v2) {
this.v1 = v1;
this.v2 = v2;
}
}
class Pair {
int v1, v2;
public Pair(int v, int w) {
v1 = v;
v2 = w;
}
}
class Node {
int data;
Node left, right;
public Node(int data) {
this.data = data;
}
}
class Tuple {
int v1, v2, idx;
public Tuple(int v, int w, int i) {
v1 = v;
v2 = w;
idx = i;
}
}
|
2031A
|
wrong_submission
|
291,633,946 |
Python 3
|
WRONG_ANSWER on test 2
|
t = int(input())
for i in range(t):
n = int(input())
lst = list(map(int,input().split()))
cnt = 0
for j in range(len(lst)-1):
if(lst == sorted(lst)):
break
if(lst[j] == lst[j+1]):
continue
else:
cnt += 1
lst[j] = lst[j + 1]
print(cnt)
|
2031A
|
wrong_submission
|
291,594,754 |
C++23 (GCC 14-64, msys2)
|
WRONG_ANSWER on test 2
|
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define pii pair<int , int >
#define coy cout<<"YES\n"
#define con cout<<"NO\n"
#define co1 cout<<"-1\n"
#define all(x) x.begin(),x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int SI=3e5+7;
ll INF=8e18+7;
int MOD=1e9+7;
int a[60];
void solve() {
int n;
cin >> n;
if (n == 1) {
cout << 0 << endl;
return;
}
int ans = 0;
int mx = 0;
for (int i=1;i<=n;i++) {
cin >> a[i];
if (a[i] >= a[i-1]) {
ans++;
}else {
mx = max(mx , ans);
ans = 1;
}
}
mx = max (mx , ans);
cout << n-mx << endl;
}
int main() {
//freopen("input.txt" , "r" , stdin);
//freopen("output.txt" , "w" , stdout);
fast
int t= 1;
cin >> t;
while (t--) solve();
}
|
2031A
|
wrong_submission
|
291,851,298 |
Python 3
|
WRONG_ANSWER on test 2
|
for _ in range(int(input())):
n = int(input())
h = [int(__) for __ in input().split(' ')]
print(len(tuple(filter(lambda hi: hi < h[0], h))))
|
2031A
|
wrong_submission
|
291,633,633 |
Java 8
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class codeforces {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
while(T>0){
int n = sc.nextInt();
int [] A = new int[n];
for(int i=0;i<n;i++){
A[i]= sc.nextInt();
}
int count = 0;
int x = A[n/2];
for(int i=0;i<n/2;i++){
if(A[i] != A[n/2]){
A[i]= x-1;
count++;
}
}
for(int i=(n/2)+1;i<n;i++){
if(A[i]!=A[n/2]){
A[i] = x+1;
count++;
}
}
System.out.println(count);
T--;
}
}
}
|
2031A
|
wrong_submission
|
296,425,145 |
Python 3
|
WRONG_ANSWER on test 2
|
t = int(input())
for _ in range(t):
n = int(input())
h = list(map(int, input().split()))
operations = 0
prev_height = 1
for i in range(n):
if h[i] < prev_height:
operations += 1
prev_height = max(prev_height, h[i])
print(operations)
|
2031A
|
wrong_submission
|
291,641,944 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.* ;
public class Pillar_H
{
public static void main(String[] args )
{
Scanner obn= new Scanner(System.in ) ;
int t ;
t= obn.nextInt() ;
for(int i= 1 ; i<= t ; ++i )
{
int n ;
n= obn.nextInt() ;
int arr[]= new int[n] ;
int ary[]= new int[n] ;
arr[0]= obn.nextInt() ;
int c= 0, cou= 1, fr= 1 ;
for(int j= 1 ; j< n ; ++j )
{
arr[j]= obn.nextInt() ;
if(arr[j- 1]== arr[j] )
{
cou++ ;
}
else
{
if(cou> fr )
{
fr= cou ;
}
cou= 1 ;
}
}
int mid= (int)(Math.ceil(n/ 2.0 ) )- 1 ;
for(int j= 0 ; j< n ; ++j )
{
if(arr[j]!= arr[mid] )
{
c++ ;
}
}
int r= Math.min(c, (n- fr ) ) ;
System.out.println(r ) ;
}
}
}
|
2031A
|
wrong_submission
|
291,614,129 |
Python 3
|
WRONG_ANSWER on test 2
|
def op(tc):
results = []
for t in tc:
n, heights = t
count = 0
target = heights[0]
for i in range(1, n):
if heights[i] < target:
count += 1
else:
target = heights[i]
results.append(count)
return results
def main():
t = int(input())
test_cases = []
for _ in range(t):
n = int(input())
heights = list(map(int, input().split()))
test_cases.append((n, heights))
results = op(test_cases)
for result in results:
print(result)
if __name__ == "__main__":
main()
|
2031A
|
wrong_submission
|
291,581,744 |
C++23 (GCC 14-64, msys2)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+10;
typedef long long ll;
void solve() {
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++) cin>>a[i];
ll ans=0;
for(int i=1;i<n;i++)
{
if(a[i]<a[i-1]) ans++;
}
cout<<ans<<'\n';
return ;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tt;
cin >> tt;
while (tt--) {
solve();
}
return 0;
}
|
2031A
|
wrong_submission
|
291,617,910 |
Python 3
|
WRONG_ANSWER on test 2
|
def count_stick(n, heights):
count = 0
l = 0
r = 1
while r < n:
if heights[l] > heights[r]:
count += heights[l] - heights[r]
heights[l] = heights[r]
l+=1
r+=1
return count
a = int(input())
results = []
for i in range(a):
b = int(input())
lst = list(map(int, input().split()))
result = count_stick(b, lst)
results.append(result)
for res in results:
print(res)
|
2031A
|
wrong_submission
|
296,859,708 |
PyPy 3-64
|
WRONG_ANSWER on test 2
|
for c in range(int(input())):
n=int(input())
narr=list(map(int,input().split()))
arr=list()
oper=0
for i in range(len(narr)-1):
if(narr[i]>narr[i+1]):
oper+=1
print(oper)
|
2031A
|
wrong_submission
|
291,595,247 |
C++23 (GCC 14-64, msys2)
|
WRONG_ANSWER on test 2
|
#define _USE_MATH_DEFINES // To use the definition of cmath
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
// mp.reserve(1024), mp.max_load_factor(0.75);
// Used only for basic types, pair and tuple.
template<typename T>
struct custom_hash_base {
size_t operator()(const T& x) const {
static const size_t seed = chrono::steady_clock::now().time_since_epoch().count();
return _Hash_bytes(&x, sizeof(x), seed);
}
};
static const auto _ = []() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("../in.txt", "r", stdin);
#endif
return nullptr;
}();
inline void solve() {
int n;
cin >> n;
vector<int> h(n);
vector<int> pre(n);
stack<int> s;
for (int i = 0; i < n; ++i) {
cin >> h[i];
while (!s.empty() && s.top() <= h[i]) {
s.pop();
}
pre[i] = s.size();
s.push(h[i]);
}
while (!s.empty()) s.pop();
int ans = n;
for (int i = n - 1; i >= 0; --i) {
while (!s.empty() && s.top() >= h[i]) {
s.pop();
}
ans = min(ans, static_cast<int>(pre[i] + s.size()));
s.push(h[i]);
}
cout << ans << '\n';
}
int main() {
int T;
for (cin >> T; T > 0; --T) {
solve();
}
return 0;
}
|
2031A
|
wrong_submission
|
291,604,385 |
PyPy 3-64
|
WRONG_ANSWER on test 2
|
test = int(input())
for i in range(test):
n = int(input())
nums = input().split()
nums = [int(i) for i in nums]
was_eq = False
if n==1:
print(0)
else:
ctr_left = 0
last_max = nums[0]
for i in range(1, n):
if nums[i] != last_max:
ctr_left+=1
ctr_right = 0
last_max = nums[-1]
for i in range(1, n):
if nums[n-1-i] != last_max:
ctr_right += 1
print(min(ctr_left, ctr_right))
|
2031A
|
wrong_submission
|
291,583,627 |
Python 3
|
WRONG_ANSWER on test 2
|
for __ in range(int(input())):
b=int(input())
c=list(map(int,input().split()))
count=0
if len(c)==1:
print("0")
elif len(c)>1:
for i in range(len(c)-1):
if c[i]>c[i+1]:
count+=1
print(count)
|
2031A
|
wrong_submission
|
302,465,211 |
Python 3
|
WRONG_ANSWER on test 2
|
def min_operations_to_non_decreasing(n, heights):
operations = 0
for i in range(n - 1):
if heights[i] > heights[i + 1]:
operations += heights[i] - heights[i + 1]
heights[i] = heights[i + 1]
return operations
def solve():
import sys
input = sys.stdin.read
data = input().split()
t = int(data[0])
index = 1
results = []
for _ in range(t):
n = int(data[index])
index += 1
heights = list(map(int, data[index:index + n]))
index += n
result = min_operations_to_non_decreasing(n, heights)
results.append(result)
for result in results:
print(result)
# Example usage:
if __name__ == "__main__":
solve()
# xY49s53rgojXeNBwKWh
|
2031A
|
wrong_submission
|
291,595,731 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
/*
____ ______ __ __ _ _ _
| __ \ | ____| \ \ / / / \ | \ | |
| | | | | |__ \ \ / / / _ \ | \| |
| | | | | __| \ \/ / / ___ \ | . ` |
| |__| | | |____ \ / / / \ \ | |\ |
|_____/ |______| \/ /_/ \_\ |_| \_|
*/
#include<bits/stdc++.h>
using namespace std;
#define suplex ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
suplex;
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int c=0;
int a,b;
cin>>a;
b=a;
for(int i=1;i<n;i++)
{
cin>>a;
if(a==b) c++;
b=a;
}
cout<<max(0,(n-c-1))<<endl;
}
return 0;
}
|
2031A
|
wrong_submission
|
306,849,789 |
Python 3
|
WRONG_ANSWER on test 2
|
def solve():
t = int(input()) # Number of test cases
for _ in range(t):
n = int(input())
h = list(map(int, input().split()))
operations = 0
for i in range(1, n):
if h[i] < h[i-1]:
operations += 1
print(operations)
solve()
|
2031A
|
wrong_submission
|
291,611,045 |
Java 8
|
WRONG_ANSWER on test 2
|
//package PenchickandModernMonument;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while (t-- > 0) {
int n = s.nextInt();
int ops = 0;
int prev = s.nextInt();
for (int i = 1; i < n; i++) {
int curr = s.nextInt();
if (prev > curr) {
ops++;
curr = prev;
}
prev = curr;
}
System.out.println(ops);
}
s.close();
}
}
|
2031A
|
wrong_submission
|
291,591,522 |
Python 3
|
WRONG_ANSWER on test 2
|
# Чтение данных
t = int(input()) # количество тестов
for _ in range(t):
n = int(input()) # количество колонн
h = list(map(int, input().split())) # высоты колонн
# Переменная для подсчета минимальных изменений
operations = 0
# Идем по массиву и проверяем, если текущее значение больше следующего
for i in range(1, n):
if h[i] < h[i - 1]: # Если текущая высота меньше предыдущей
operations += 1 # Понадобится операция
h[i] = h[i - 1] # Приводим текущую колонну к высоте предыдущей (это минимальный вариант)
# Выводим количество операций для текущего теста
print(operations)
|
2031A
|
wrong_submission
|
291,631,306 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int m=0;m<t;m++){
int n=sc.nextInt();
int[] A=new int[n];
for(int k=0;k<n;k++){
A[k]=sc.nextInt();
}
int count=0;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
if(A[i]==A[j]){
count++;
}
}
}
System.out.println(n-count-1);
}
}
}
|
2031A
|
wrong_submission
|
291,595,056 |
PyPy 3
|
WRONG_ANSWER on test 2
|
for _ in range(int(input())):
N = int(input())
H = list(map(int, input().split()))
stack = [H[-1]]
ans = 0
for i in range(N-1)[::-1]:
h = H[i]
if stack and stack[-1] < h:
ans += 1
stack.append(h)
print(ans)
|
2031A
|
wrong_submission
|
291,606,384 |
Python 3
|
WRONG_ANSWER on test 2
|
t = int(input())
for _ in range(t):
n = int(input())
h = list(map(int, input().split()))
operations = 0
for i in range(1, n):
if h[i] < h[i - 1]:
operations += 1
h[i] = h[i - 1]
print(operations)
|
2031A
|
wrong_submission
|
291,595,473 |
C++23 (GCC 14-64, msys2)
|
WRONG_ANSWER on test 2
|
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
typedef struct node{
}node;
void solve(){
ll n;cin>>n;
vector<ll>arr(n);for(int i=0;i<n;i++)cin>>arr[i];
ll ans=0,sum=0;
for(int i=0;i<n;){
ll index=i;
while(index<n&&arr[index]==arr[i])index++;
if(index-i==1)ans++;
i=index;
}
if(ans==n)cout<<n-1<<endl;
else cout<<ans<<endl;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
ll t=1;
cin>>t;
while(t--){
solve();
}
return 0;
}
|
2031A
|
wrong_submission
|
291,592,631 |
PyPy 3-64
|
WRONG_ANSWER on test 2
|
def split2(string):
str1=""
arr=[]
for i in string:
if i!=" ":
str1=str1+i
else:
arr.append(int(str1))
str1=""
arr.append(int(str1))
return arr
t=int(input())
for i in range(t):
l=int(input())
arr=split2(input())
beginning=0
ending=0
for x in range(l):
if arr[x]==arr[0]:
beginning+=1
if arr[l-1-x]==arr[l-1]:
ending+=1
print(l-max(beginning,ending))
|
2031A
|
wrong_submission
|
300,234,193 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
InputReader sc = new InputReader();
PrintWriter out = new PrintWriter(System.out);
int t = sc.nextInt();
while (t-- > 0) {
int cnt = 0;
int prev = Integer.MIN_VALUE;
int n = sc.nextInt();
for(int i = 0; i < n; i++) {
int height = sc.nextInt();
if(height >= prev) {
prev = height;
}
else {
cnt++;
}
}
out.println(cnt);
}
out.close();
}
static class InputReader {
private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
private StringTokenizer st;
public String next() throws IOException {
while (st == null || !st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
}
}
|
2031A
|
wrong_submission
|
291,627,382 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class PenMonument {
static void solve(int arr[], int n) {
int mid = n / 2;
int cnt = 0;
for (int i = 0; i < mid; i++) {
if (arr[i] == arr[mid]) {
continue;
} else {
cnt++;
}
}
for (int i = mid + 1; i < n; i++) {
if (arr[i] == arr[mid]) {
continue;
} else {
cnt++;
}
}
System.out.println(cnt);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
solve(arr, n);
}
sc.close();
}
}
|
2031A
|
wrong_submission
|
291,756,046 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class Demo{
public static int find(int arr[],int n)
{
if(n==1)
{
return 0;
}
int count=0;
for(int i=0;i<n-1;i++)
{
if(arr[i]>arr[i+1])
{
count++;
}
}
return count;
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int no=sc.nextInt();
for(int i=0;i<no;i++)
{
int n=sc.nextInt();
int arr[]=new int[n];
for(int j=0;j<n;j++)
{
arr[j]=sc.nextInt();
}
System.out.println(find(arr,n));
}
}
}
|
2031A
|
wrong_submission
|
291,718,011 |
PyPy 3-64
|
WRONG_ANSWER on test 2
|
tests = int(input())
for i in range(tests):
numberOfTowers = int(input())
towers = list(map(int, input().split()))
count = len(towers)
for j in range(0, len(towers)):
same = 0
for k in range(j, len(towers)):
if towers[k] == towers[j]:
same += 1
if same >= 2:
count -= same
if count == len(towers):
print(count - 1)
else:
print(count)
|
2031A
|
wrong_submission
|
291,594,882 |
C++23 (GCC 14-64, msys2)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
using namespace std;
#define fastio() \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define nline "\n"
#define sp " "
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define andd &&
#define orr ||
#define nott !
#define set_bits __builtin_popcountll
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define yes cout << "YES" << nline
#define no cout << "NO" << nline
#define yesno(f) \
if (f) \
yes; \
else \
no
#define noyes(f) \
if (!f) \
yes; \
else \
no
#define out(x) cout << x << nline
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rev(i, a, b) for (ll i = a; i >= b; i--)
#define show(v, s, n) \
for (ll i = s; i < n; i++) \
cout << v[i] << sp;
#define show_rev(v, s, n) \
for (ll i = s; i >= n; i--) \
cout << v[i] << sp;
#define show_pair(v, s, n) \
for (ll i = s; i < n; i++) \
cout << v[i].ff << sp << v[i].ss << nline;
#define vl vector<ll>
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpair vector<pair<ll, ll>>
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key
#ifndef ONLINE_JUDGE
#define debug(x) \
cerr << #x << " "; \
_print(x); \
cerr << endl;
#else
#define debug(x)
#endif
void _print(ll t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(lld t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(ull t) { cerr << t; }
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p)
{
cerr << "{";
_print(p.ff);
cerr << ",";
_print(p.ss);
cerr << "}";
}
template <class T>
void _print(vector<T> v)
{
cerr << "[ ";
for (T i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}
template <class T>
void _print(set<T> v)
{
cerr << "[ ";
for (T i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}
template <class T>
void _print(multiset<T> v)
{
cerr << "[ ";
for (T i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v)
{
cerr << "[ ";
for (auto i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}
void solve()
{
ll n;
cin >> n;
vl a(n);
rep(i, 0, n) cin >> a[i];
if (n == 1)
{
out(0);
return;
}
ll ans = 0;
for (ll i = 0; i < n - 1; i++)
{
if (a[i] > a[i + 1])
{
a[i] == a[i + 1];
ans++;
}
}
out(ans);
}
int main()
{
fastio();
#ifndef ONLINE_JUDGE
freopen("Error.txt", "w", stderr);
#endif
int t;
cin >> t;
while (t--)
solve();
#ifndef ONLINE_JUDGE
cerr << "Time : " << (1000 * ((double)clock()) / (double)CLOCKS_PER_SEC) * 0.001 << "s\n";
#endif
}
|
2031A
|
wrong_submission
|
291,606,030 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include<bits/stdc++.h>
#include<string>
#include<vector>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#define int long long
int MOD = 1e9 + 7;
using namespace std;
//int arr[1000000];
void init_code() {
#ifndef ONLINE_JUDGE
freopen("input1.txt", "r", stdin);
freopen("output1.txt.txt", "w", stdout);
#endif
}
int pow(int a, int b) {
if (b == 0) {
return 1;
}
int half = pow(a, b / 2);
int ans;
if (b % 2 == 0) {
ans = 1LL * half * half;
}
else {
ans = 1LL * half * half;
ans = 1LL * ans * a;
}
return ans;
}
int div_count(int a )
{
int d = 0;
for (int i = 1 ; i <= sqrt(a) ; i++)
{
if (a % i == 0)
{
d++;
if (i != a / i)
d++;
}
}
return d ;
}
int sqrt_binary(int a) //only for perfect squares
{
int st = 1;
int end = a;
int mid = 0;
while (st <= end)
{
mid = st + (end - st) / 2;
if ( mid == a / mid )
{
break;
}
if (mid < (a) / mid )
{
st = mid + 1;
}
else
{
end = mid - 1;
}
}
return mid ;
}
int gcd(int a , int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
/*
vector<bool> isPrime(n + 1, true);
isPrime[0] = isPrime[1] = false;
for(int i = 1; i <= n; i++) {
if(!isPrime[i]) continue;
// we are here, this means i is prime
for(int j = i + i; j <= n; j += i) {
isPrime[j] = false;
}
}
*/
bool contains(string s)
{
bool b = false;
if (s.length() == 4)
if (s == "1100")
b = true;
else
{
for (int i = 0 ; i < s.length() - 5 ; i++)
{
if (s[i] == '1' && s[i + 1] == '1' && s[i + 2] == '0' && s[i + 3] == '0')
{
b = true;
break;
}
}
}
return b;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
init_code();
int tests = 0 ;
cin >> tests;
while (tests--)
{
int n = 0;
cin >> n;
int arr[n];
for (int i = 0 ; i < n ; i++)
cin >> arr[i];
int ans = 0;
for (int i = 0 ; i < n - 1 ; i++)
{
if (arr[i] > arr[i + 1])
{
arr[i ] = arr[i + 1];
ans = ans + 1;
}
}
cout << ans << "\n";
}
}
/*0223201
0223201
0211122*/
|
2031A
|
wrong_submission
|
291,952,521 |
Python 3
|
WRONG_ANSWER on test 2
|
import sys
def solve():
input = sys.stdin.read
data = input().splitlines()
t = int(data[0])
idx = 1
results = []
for _ in range(t):
n = int(data[idx])
idx += 1
h = list(map(int, data[idx].split()))
idx += 1
operations = 0
for i in range(1, n):
if h[i] < h[i - 1]:
operations += 1
results.append(str(operations))
sys.stdout.write("\n".join(results) + "\n")
if __name__ == "__main__":
solve()
|
2031A
|
wrong_submission
|
291,632,826 |
Python 3
|
WRONG_ANSWER on test 2
|
t = int(input())
for i in range(t):
n = int(input())
pillars = list(map(int,input().split()))
max_seq=0
temp_seq=0
for j in range(n-1):
if pillars[j] == pillars[j+1]:
temp_seq += 1
if temp_seq > max_seq:
max_seq = temp_seq
else:
temp_seq = 0
print(n-1-max_seq)
|
2031A
|
wrong_submission
|
291,594,291 |
PyPy 3-64
|
WRONG_ANSWER on test 2
|
from collections import Counter
for _ in range(int(input())):
n = int(input())
h = list(map(int, input().split()))
freq = Counter(h)
s = 0
for val in freq.values():
s += val
print(s-freq[max(freq)])
|
2031A
|
wrong_submission
|
291,593,856 |
C++23 (GCC 14-64, msys2)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for(int i = a; i <= n; i++)
#define per(i, n, a) for(int i = n; i >= a; i--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define PII map<int,int>
#define PI pair<int,int>
#define VI vector<int>
typedef long long ll;
const int maxn = INT32_MAX;
int t, n, ans;
VI a(100);
void solve(){
cin >> n;
ans = 0;
int cnt = 1;
rep(i, 1, n)
cin >> a[i];
int num = a[1], maxn = 1;
rep(i, 2, n){
if(a[i] == a[i-1]){
cnt++;
}
else if(cnt > maxn){
maxn = cnt;
num = a[i-1];
cnt = 1;
}
else {
cnt = 1;
continue;
}
//cout << num << endl;
}
rep(i, 1, n){
if(a[i] != num)
ans++;
//cout << ans << endl;
}
cout << ans << endl;
//cout << num << endl;
//ans = 0;
}
int main()
{
IOS
cin >> t;
while(t--){
solve();
}
return 0;
}
|
2031A
|
wrong_submission
|
291,584,810 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class Ques1 {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
long t=sc.nextLong();
while(t-->0) {
long n=sc.nextLong();
long arr[]=new long[(int)n];
for(int i=0;i<n;i++) {
arr[i]=sc.nextLong();
}
if(strict(arr)) {
System.out.println(n-1);
}
else if(n==1) {
System.out.println(0);
}
else {
System.out.println(unique(arr));
}
}
sc.close();
}
public static boolean strict(long arr[]) {
boolean b=true;
for(int i=0;i<arr.length-1;i++) {
if(arr[i]>arr[i+1]) {
continue;
}
else {
b=false;
break;
}
}
return b;
}
public static int unique(long arr[]) {
HashSet<Integer> set=new HashSet<>();
for(int i=0;i<arr.length;i++) {
set.add((int)arr[i]);
}
return arr.length-set.size();
}
}
|
2031A
|
wrong_submission
|
291,879,348 |
Java 8
|
WRONG_ANSWER on test 2
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Integer testCase = scanner.nextInt();
while (testCase-->0) {
Integer pillar_numbers = scanner.nextInt();
Integer last_height = -1;
Integer min_numbers = 0;
Integer pillar_height;
while(pillar_numbers-->0){
pillar_height = scanner.nextInt();
if(pillar_height != last_height){
last_height = pillar_height;
min_numbers++;
}
}
if(min_numbers>0){
min_numbers--;
}
System.out.println(min_numbers);
}
}
}
|
2031A
|
wrong_submission
|
291,593,504 |
C++20 (GCC 13-64)
|
WRONG_ANSWER on test 2
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(n);
for (auto& it : a) cin >> it;
long long ans = 0;
for (int i = 1; i < n; i++) {
if(a[i] < a[i - 1]) ans++;
}
cout << ans << '\n';
}
return 0;
}
|
2031A
|
wrong_submission
|
291,611,785 |
Python 3
|
WRONG_ANSWER on test 2
|
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split()))
b=[]
s=0
for i in range(n-1):
if a[i]>a[i+1]:
s+=a[i]-a[i+1]
a[i]=a[i+1]
elif a[i]==a[i+1]:
continue
b.append(s)
for j in b:
print(j)
|
2031A
|
wrong_submission
|
291,585,433 |
PyPy 3-64
|
WRONG_ANSWER on test 2
|
# Problem: A. Penchick and Modern Monument
# Contest: Codeforces - Codeforces Round 987 (Div. 2)
# URL: https://codeforces.com/contest/2031/problem/0
# Memory Limit: 256 MB
# Time Limit: 1000 ms
from collections import deque
import heapq
def main():
n = int(input())
c = 0
#x,y = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
for i in a:
if i == a[0]:
c+=1
return n - c
#c = [list(i) for i in input().split()]
#x, y = [int(i) for i in input().split()]
#s = input()
#t = input()
#m = [list(map(int,row.split())) for row in input().splitlines()]
#a = [list(map(int, input().split())) for _ in range(n)]
if __name__ == "__main__":
t = int(input())
for _ in range(t):
print(main())
|
2031A
|
wrong_submission
|
291,580,294 |
Java 8
|
WRONG_ANSWER on test 2
|
import java.util.*;
import java.io.*;
public class Main{
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br=new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while(st==null || !st.hasMoreTokens()){
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt(){
return Integer.parseInt(next());
}
long nextLong(){
return Long.parseLong(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
String nextLine(){
String str="";
try {
str=br.readLine().trim();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
}
static class FastWriter {
private final BufferedWriter bw;
public FastWriter() {
this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
}
public void print(Object object) throws IOException {
bw.append("" + object);
}
public void println(Object object) throws IOException {
print(object);
bw.append("\n");
}
public void close() throws IOException {
bw.close();
}
}
// private static class Pair{
// int x,y;
// Pair(int x,int y){
// this.x=x;
// this.y=y;
// }
// }
// private static int pow(int b,int p,int m){
// long res=1;
// while(p>0){
// if ((p&1)==1) {
// res=((res%m)*(b%m))%m;
// }
// b%=m;
// b*=b;
// b%=m;
// p>>=1;
// }
// return (int)(res%m);
// }
// private static int gcd(int a,int b){
// while(b!=0){
// int t=b;
// b=a%b;
// a=t;
// }
// return a;
// }
//private static int mod=(int)(1e9)+7;
public static void main(String[] args) {
try {
FastReader in=new FastReader();
FastWriter out = new FastWriter();
StringBuilder ans=new StringBuilder("");
int testCases=in.nextInt();
while(testCases-- > 0){
int n=in.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++) a[i]=in.nextInt();
int cnt=1;
int x=a[0];
for(int i=1;i<n;i++) {
if (x!=a[i]) break;
cnt++;
}
ans.append((n-cnt)+"\n");
}
out.println(ans);
out.close();
} catch (Exception e) {
return;
}
}
}
|
2031A
|
wrong_submission
|
291,781,823 |
Java 21
|
WRONG_ANSWER on test 2
|
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0) {
int n = sc.nextInt();
int arr[] = new int[n];
for(int i = 0 ;i < n ;i++) {
arr[i] = sc.nextInt();
}
int mid = (n >> 1);
int l = mid;
int r = mid;
while(l >=0 && arr[l] == arr[mid]) l--;
while(r<n && arr[r] == arr[mid]) r++;
if((n & 1) == 0 ) {
System.out.println(n-r+l);
}
else {
System.out.println(n-r+l+1);
}
}
}
}
|
2031A
|
wrong_submission
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.