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
304,787,042
Java 21
WRONG_ANSWER on test 2
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import static java.lang.Math.*; public class Solution { private static final boolean USE_TESTCASES = true; public static void main(String[] marcoIsAGenius) { FastReader fr = new FastReader(); PrintWriter out = new PrintWriter(System.out); int T; if (USE_TESTCASES) T = fr.nextInt(); else T = 1; testcases: while (T --> 0) { int n =fr.nextInt(); int[] a = fr.nextIntArray(n); if (n == 1) out.println(0); else { int cnt = 0; for (int i = 1; i < n; i++) { if (a[i] == a[i-1]) cnt+=2; } if (cnt > 0) out.println(n - cnt); else out.println(n-1); } } out.close(); } //Template private static long gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); } private static long lcm(int a, int b) { return (a / gcd(a, b)) * b; } private static ArrayList<Integer> findPrimes(int n) { boolean[] isPrime = new boolean[n + 1]; Arrays.fill(isPrime, true); for (int i = 2; i * i <= n; i++) { if (isPrime[i]) { for (int j = i * i; j <= n; j += i) isPrime[j] = false; } } ArrayList<Integer> primes = new ArrayList<>(); for (int i = 2; i <= n; i++) { if (isPrime[i]) primes.add(i); } return primes; } private static boolean[] getPrimeArray(int n) { boolean[] isPrime = new boolean[n + 1]; Arrays.fill(isPrime, true); //Set one and zero to false, because they're not primes isPrime[0] = false; 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; } } return isPrime; } private static void heapsAlgorithm(int[] arr, int k) { if (k == 1) { //Process the current permutation System.out.println(Arrays.toString(arr)); } else { heapsAlgorithm(arr, k-1); for (int i = 0; i < k-1; i++) { int t; if (k % 2 == 0) { t = arr[i]; arr[i] = arr[k-1]; } else { t = arr[0]; arr[0] = arr[k-1]; } arr[k-1] = t; heapsAlgorithm(arr, k - 1); } } } private static class Pair<A, B> { public A a; public B b; public Pair(A a, B b) { this.a = a; this.b = b; } @Override public boolean equals(Object o) { if (o == null) return false; if (o.getClass() != this.getClass()) return false; Pair<?, ?> pair = (Pair<?, ?>) o; return Objects.equals(a, pair.a) && Objects.equals(b, pair.b); } @Override public String toString() { return a + " " + b; } } private static class FastReader { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); } catch (IOException ignored) {} 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 { if(st.hasMoreTokens()){ str = st.nextToken("\n"); } else{ str = br.readLine(); } } catch (IOException ignored) {} return str; } int[] nextIntArray(int n) { int[] arr=new int[n]; for(int i=0;i<n;i++)arr[i]=nextInt(); return arr; } ArrayList<Integer> nextIntArrayList(int n) { ArrayList<Integer> arr=new ArrayList<>(n); for(int i=0;i<n;i++)arr.add(nextInt()); return arr; } String[] nextStrArray(int n) { String[] arr=new String[n]; for(int i=0;i<n;i++)arr[i]=next(); return arr; } } }
2031A
wrong_submission
304,535,593
Python 3
WRONG_ANSWER on test 2
def min_operations(pillar_heights): operations = 0 prev_height = 1 for height in pillar_heights: if height < prev_height: operations += prev_height - height prev_height = height return operations t = int(input()) for _ in range(t): n = int(input()) pillar_heights = list(map(int, input().split())) print(min_operations(pillar_heights)) # 6acJxZOfmVh5qiUe7p2
2031A
wrong_submission
296,241,880
Python 3
WRONG_ANSWER on test 2
from collections import Counter v = int(input("")) l2 = [] for i in range(v): s = int(input("")) l = list(map(int,input().split())) l1 = set(l) l1 = list(l1) count = 0 if len(l1) == len(l): for i in range(len(l)): if l1[i] != l[i]: count+=1 l2.append(count) else: c = Counter(l) m = None mx = 0 for x in l: if c[x] > mx: m = x mx = c[x] j = l.index(m) g = sum(1 for x in l[:j] if x > m) s = sum(1 for x in l[j+1:] if x < m) count = g+s l2.append(count) for i in (l2): print(i)
2031A
wrong_submission
291,623,323
Python 3
WRONG_ANSWER on test 2
def min_operations_to_non_decreasing(n,h): operations = 0 for j in range(1, n): if h[j] < h[j - 1]: operations += 1 h[j] = h[j - 1] return operations for _ in range(int(input())): n=int(input()) h=list(map(int,input().split())) print(min_operations_to_non_decreasing(n,h))
2031A
wrong_submission
295,805,682
Python 3
WRONG_ANSWER on test 2
for _ in range(int(input())): n=int(input()) vec=[int(x) for x in input().split()] mas=0 con=1 for i in range(n-1): if vec[i]==vec[i+1]: con+=1 else: mas=max(mas,con) mas=max(mas,con) print(n-mas)
2031A
wrong_submission
291,648,542
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]){ arr[i+1]=arr[i]; cnt++; } else if(arr[i]==arr[i+1]){ int idx=i; while(idx<n-1&&arr[idx]==arr[idx+1]){ idx++; } i=idx-1; } } System.out.println(cnt); } } }
2031A
wrong_submission
291,625,089
Java 21
WRONG_ANSWER on test 2
import java.util.*; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); int heights[] = new int[n]; for(int i = 0 ; i < n; i++){ heights[i] = sc.nextInt(); } int operations = 0; for(int i = n-2 ; i >= 0 ; i--){ if(heights[i]>heights[i+1]){ operations++; heights[i+1] = n; } } System.out.println(operations); } sc.close(); } }
2031A
wrong_submission
304,222,172
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(); // Number of test cases while (t-- > 0) { int n = scanner.nextInt(); // Number of pillars 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]) { h[i] = h[i - 1]; operations++; } } System.out.println(operations); } scanner.close(); } } // AztRxkrDYNUoB5q6H8b
2031A
wrong_submission
291,612,076
PyPy 3-64
WRONG_ANSWER on test 2
n = int(input()) for _ in range(n): k = int(input()) lis = list(map(int, input().split())) ans = 1 left = 0 cnt = 1 for i in range(1, k-1): if lis[i] == lis[left]: cnt += 1 else: ans = max(ans, cnt) left = i cnt = 1 print(k - max(ans, cnt))
2031A
wrong_submission
295,352,456
Python 3
WRONG_ANSWER on test 2
p=int(input()) ll=[] for i in range (p): c=0 t=0 g=int(input()) l=input().split(' ') for j in range(g): f=int(l[0]) if int(l[j])<f: c+=1 for j in range(g): f=int(l[-1]) if int(l[j])>f: t+=1 if t<c: c=t ll.append(c) for i in range(p): print(ll[i])
2031A
wrong_submission
291,586,304
PyPy 3-64
WRONG_ANSWER on test 2
from sys import stdin from math import ceil as ce,lcm,gcd,sqrt input = lambda: stdin.readline().rstrip() def is_prime(x): if x <= 2: return True i = 2 while i * i <= x: if x % i == 0: return False i += 1 return True for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) kol = 0 for i in range(n - 1): if a[i] != a[i + 1]: kol += 1 print(kol)
2031A
wrong_submission
291,640,061
PyPy 3-64
WRONG_ANSWER on test 2
def solve(): t = int(input()) for _ in range(t): n = int(input()) hskatienoob = list(map(int, input().split())) iamkatienoobdunnotheanswer = 0 maximkatienooob = hskatienoob[0] for i in range(1, n): if hskatienoob[i] < maximkatienooob: iamkatienoobdunnotheanswer += 1 else: maximkatienooob = hskatienoob[i] print(iamkatienoobdunnotheanswer) solve()
2031A
wrong_submission
291,613,382
Java 21
WRONG_ANSWER on test 2
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); int[] h = new int[n]; for (int i = 0; i < n; i++) { h[i] = sc.nextInt(); } int ans = solve(h); System.out.println(ans); } } public static int solve(int[] h) { int n = h.length; if(n==1) return 0; boolean flag = true; for(int i=0; i<n-1; i++){ if(h[i]>h[i+1]) flag = false; } if(flag) return 0; int operations = 0; int ele = h[0]; int index = 0; for(int i=1; i<n; i++){ if(h[i]!=ele){ index=i; break; } } return n-index; } }
2031A
wrong_submission
292,207,617
Python 3
WRONG_ANSWER on test 2
for q in range(int(input())): n = int(input()) h = set(map(int, input().split())) print(len(h)-1)
2031A
wrong_submission
291,625,101
PyPy 3-64
WRONG_ANSWER on test 2
for _ in range(int(input())): n = int(input()) res = 0 zxc = list(map(int, input().split())) for i in range(n - 1): if zxc[i] > zxc[i + 1]: res += 1 zxc[i + 1] = zxc[i] print(res)
2031A
wrong_submission
291,931,578
Python 3
WRONG_ANSWER on test 2
n = int(input()) for x in range(n): k = int(input()) lst = list(map(int, input().split())) start = lst[0] cnt = 0 for x in lst: if start > x: cnt += 1 print(cnt)
2031A
wrong_submission
291,607,136
Java 21
WRONG_ANSWER on test 2
import java.util.*; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); int heights[] = new int[n]; for(int i = 0 ; i < n; i++){ heights[i] = sc.nextInt(); } int operations = 0; for(int i = 1 ; i < n ; i++){ if(heights[i]<heights[i-1]){ operations++; heights[i] = heights[i-1]; } } System.out.println(operations); } sc.close(); } }
2031A
wrong_submission
291,639,087
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(); while(t-->0) { int n=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) { a[i]=sc.nextInt(); } if(n==1) { System.out.println(0); } else { int co=0; int c[]=new int[n+1]; for(int i=0;i<n;i++) { c[a[i]]++; } for(int i=0;i<n+1;i++) { if(c[i]>1) { co+=c[i]-1; } } System.out.println(n-1-co); } } } }
2031A
wrong_submission
291,591,857
PyPy 3-64
WRONG_ANSWER on test 2
for _ in range(int(input())): n = int(input()) a = list(map(int,input().split(' '))) mx = a[0] c = 0 for i in range(1,n): # print('i',i) if mx>a[i]: c +=1 mx = max(a[i],mx) print(c)
2031A
wrong_submission
291,666,348
Java 8
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(); while(t-- !=0){ int n=sc.nextInt(); int[] arr=new int[n]; int min=Integer.MAX_VALUE; int max=Integer.MIN_VALUE; int count=0; for(int i=0;i<n;i++){ arr[i]=sc.nextInt(); min=Math.min(min,arr[i]); max=Math.max(max,arr[i]); } int mid=n/2; for(int i=0;i<n/2;i++){ if(arr[i]>arr[i+1]){ arr[i]=min; count++; if(i==n/2){ break; } } } for(int i=(n/2)+1;i<n;i++){if(arr[i]<arr[i-1]){ arr[i]=max; count++; if(i==n-1){ break; } } } if(n==1){ System.out.println("0"); } else{ System.out.println(count); } } } }
2031A
wrong_submission
291,589,053
PyPy 3-64
WRONG_ANSWER on test 2
t = int(input()) for i in range(t): h = int(input()) k = list(map(int,input().split())) print(k[0]-k[-1])
2031A
wrong_submission
291,618,569
Python 3
WRONG_ANSWER on test 2
t=int(input()) for _ in range(t): n=int(input()) h=list(map(int,input().split(" "))) le=len(h) mle=le*-1 if len(h)==1: print(0) continue else: c=0 for i in range(n-1): if h[i]>h[i+1]: c+=1 h[i],h[i+1]=h[i+1],h[i] else: continue print(c)
2031A
wrong_submission
291,605,472
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(); while(t-->0) { int n=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) { a[i]=sc.nextInt(); } if(n==1) { System.out.println(0); } else { int c=0; for(int i=0;i<n-1;i++) { if(a[i]>a[i+1]) { c++; } } System.out.println(c); } } } }
2031A
wrong_submission
291,618,701
Python 3
WRONG_ANSWER on test 2
def INT(): return int(input()) def STR(): return str(input()) def il(): return list(map(int,input().split())) def sl(): return list(map(str,input().split())) def im(): return map(int,input().split()) def smap(): return map(str,input().split()) def out(a): print(a) def out2(a,b): print(a,b) def out3(a,b,c): print(a,b,c) def srt(a): return sorted(a) def low(a): return a.lower() def up(a): return a.upper() def cnt(l,m): return l.count(m) def sums(a): a = str(a) w = 0 for i in range(len(str(a))): w+=int(a[i]) return str(w) def discstr(a): a = str(a) w = [] for i in range(len(a)): if low(a[i]) not in w: w.append(a[i]) return "".join(w) def discl(a): w = [] for i in range(len(a)): if a[i] not in w: w.append(a[i]) if len(a)==len(w): return True else: return False def setl(a): w = [] for i in range(len(a)): if a[i] not in w: w.append(a[i]) out(w) for i in range(INT()): d = INT() x = il() j = 0 for i in range(d-1): if x[i]>x[i+1]: j+=1 out(j)
2031A
wrong_submission
292,128,195
PyPy 3-64
WRONG_ANSWER on test 2
t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split())) ans = 0 last = a[0] for i in a: if i < last: ans += 1 last = i print(ans)
2031A
wrong_submission
291,591,095
Python 3
RUNTIME_ERROR on test 2
t=int(input()) for i in range(t): n=int(input()) l=list(map(int, input().split())) c=1 cl=[] if n>1: for j in range(n-1): if l[j]==l[j+1]: c+=1 else: cl.append(c) c=1 cl.sort(reverse=True) print(n-cl[0]) else: print(0)
2031A
wrong_submission
291,588,668
Python 3
WRONG_ANSWER on test 2
num = int(input()) for x in range(num): count = 0 pil_num = int(input()) pil = list(map(int, input().split())) pil.sort() # print(pil) for x in range(1, len(pil)): if pil[x] > pil[x - 1]: count += 1 print(count)
2031A
wrong_submission
297,103,318
Python 3
WRONG_ANSWER on test 2
import collections n=int(input('')) for i in range(n): a=int(input('')) l=[int(x) for x in input().split()] t=0 for i in range(a-1): if l[i]==l[i+1]: t+=1 else: break print(a-t-1)
2031A
wrong_submission
296,044,709
PyPy 3-64
WRONG_ANSWER on test 2
t = int(input()) for _ in range(t): n=int(input()) l=list(map(int,input().split())) s = set(l) print(len(s)-1)
2031A
wrong_submission
291,664,425
Java 21
WRONG_ANSWER on test 2
import java.util.*; public class CD1511B { 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]; Set<Integer> set = new HashSet<>(); for(int i = 0; i < n ; i++){ arr[i] = sc.nextInt(); set.add(arr[i]); } System.out.println(set.size() - 1); } } }
2031A
wrong_submission
291,596,611
PyPy 3-64
WRONG_ANSWER on test 2
t = int(input()) for i in range(t): n = int(input()) h = list(map(int, input().split())) if n == 1: print(0) else: for i in range(n): if i == n-1: print(0) break elif h[i] != h[i+1]: print(n-1-(i)) break
2031A
wrong_submission
292,446,597
C++20 (GCC 13-64)
WRONG_ANSWER on test 2
#include<bits/stdc++.h> using namespace std; const int N=5e5; int n,a[N]; void solve(){ cin>>n; map<int,int> mp; for(int i=1;i<=n;i++){ cin>>a[i]; mp[a[i]]=1; } cout<<mp.size()-1<<'\n'; } signed main(){ ios::sync_with_stdio(false); cin.tie(0); int t=1; cin>>t; while(t--){ solve(); } return 0; }
2031A
wrong_submission
291,592,780
C++23 (GCC 14-64, msys2)
WRONG_ANSWER on test 2
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 3e5+9; int a[N], b[N]; void haha() { int n;cin >> n;int cnt =0; if(n == 1) cnt = 0; else if(n == 2) { if(a[1] > a[2]) cnt = 1; } else if(n >= 3) { for(int i = 1; i <= n; i++) { cin >> a[i]; b[i] = a[i]; } sort(b+1, b+n+1); int x = b[(n+1)/2]; //cout << x << "\n"; for(int i = 1; i <= n/2; i++) if(a[i] > x) cnt ++; for(int i = n/2+1; i <= n; i++) if(a[i] < x) cnt ++; } cout << cnt << "\n"; return ; } signed main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int t; cin >> t; while(t--) haha(); return 0; }
2031A
wrong_submission
295,352,003
PyPy 3-64
WRONG_ANSWER on test 2
test_times=int(input()) sve=[] for i in range(test_times): lenth=int(input()) pillars=input().split() pillars=[int(m) for m in pillars] def sort_pillars(pillars): times=0 mark=(len(pillars))//2 for m in range(len(pillars)): if m<mark: if pillars[m]>pillars[mark]: times+=1 elif m>mark: if pillars[m]<pillars[mark]: times+=1 return times sve.append(sort_pillars(pillars)) for i in sve: print(i)
2031A
wrong_submission
292,335,364
PyPy 3-64
WRONG_ANSWER on test 2
t=int(input()) l=[] for i in range(0,t): a=0 n=int(input()) p=list(map(int,input().split())) if len(p)==1: l.append(0) else: s=set(p) s=list(s) for j in range(0,len(s)): if p.count(s[j])>1: a+=1 else: a+=0 if a==0: l.append(len(p)-1) else: d=(len(p)//2) if p.count(p[d])>1: l.append(len(p)-p.count(p[d])) else: l.append(len(p)-1) for k in range(0,len(l)): print(l[k])
2031A
wrong_submission
291,592,456
Java 21
WRONG_ANSWER on test 2
import java.util.*; public class Solution { 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 count = 0; for (int i = 1; i < n; i++) { if (arr[i] < arr[i - 1]) { count++; arr[i] = arr[i - 1]; } } System.out.println(count); } sc.close(); } }
2031A
wrong_submission
291,748,496
C++23 (GCC 14-64, msys2)
WRONG_ANSWER on test 2
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,t; cin>>t; while(t--){ int c1=0,c2=0; cin>>n; int h[n]; for(int i=0;i<n;i++){ cin>>h[i]; } for(int i=n/2-1;i>=0;i--){ if(h[i]!=h[n/2]) c1++; } for(int i=n/2+1;i<n;i++){ if(h[i]!=h[n/2]) c2++; } cout<<c1+c2<<"\n"; } return 0; }
2031A
wrong_submission
291,578,262
PyPy 3-64
WRONG_ANSWER on test 2
import sys, math from collections import * from bisect import * from types import GeneratorType from random import randrange MOD = 1000000007 # MOD = 998244353 RANDOM = randrange(2**62) def wrap(x): return x ^ RANDOM def bootstrap(f, stack=[]): def wrappedfunc(*args, **kwargs): if stack: return f(*args, **kwargs) else: to = f(*args, **kwargs) while True: if type(to) is GeneratorType: stack.append(to) to = next(to) else: stack.pop() if not stack: break to = stack[-1].send(to) return to return wrappedfunc def linp(): return list(map(int, sys.stdin.readline().split())) def minp(): return map(int, sys.stdin.readline().split()) def sinp(): return sys.stdin.readline().rstrip('\n'); def inp(): return int(sys.stdin.readline()) for t in range(inp()): n = inp() lst = linp() cnt = 0 for i in range(1, n): if lst[i-1] > lst[i]: cnt += 1 print(cnt)
2031A
wrong_submission
291,584,046
PyPy 3-64
WRONG_ANSWER on test 2
for _ in range(int(input())): n = int(input()) h = list(map(int, input().split())) count = 0 for i in range(1, n): if h[i] < h[i - 1]: count += 1 print(count)
2031A
wrong_submission
292,382,085
PyPy 3-64
WRONG_ANSWER on test 2
n = int(input()) for i in range(n): m = int(input()) arr = [] distinct = [] prev = -1 arr = [int(x) for x in input().split()] for i in range(len(arr)): if (arr[i] != prev): distinct.append(arr[i]) prev = arr[i] def find_most_common_number(): winner = 0 max_count = -1 for index in range(len(distinct)): count = 0 for i in range(len(arr)): if arr[i] == distinct[index]: count += 1 if count > max_count: max_count = count winner = index return winner w = find_most_common_number() start, end = 0, 0 flag = False for i in range(len(arr)): if (arr[i] == distinct[w]): start = i flag = True if flag and arr[i] != distinct[w]: end = i - 1 break copy = arr.copy() for i in range(0, start): copy[i] = arr[end] for i in range(end + 1, len(arr)): copy[i] = arr[start] count = 0 for i in range(len(arr)): if(copy[i] != arr[i]): count += 1 print(count)
2031A
wrong_submission
291,624,305
PyPy 3-64
WRONG_ANSWER on test 2
import collections # 2 2 1-> op = 1 # 2 1 1-> op = 2 # 2 2 1 1 1 -> 3 def solve(n,h): fq = collections.Counter(h) res = [] for key,val in fq.items(): res.append([key,val]) res.sort() # print(res,res[-1,[1]]) return n - res[-1][1] t = int(input()) for _ in range(t): n = int(input()) h = list(map(int,input().split())) print(solve(n,h))
2031A
wrong_submission
291,636,954
Java 21
WRONG_ANSWER on test 2
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int numCases = Integer.parseInt(reader.readLine().trim()); List<int[]> cases = new ArrayList<>(); for (int i = 0; i < numCases; i++) { int n = Integer.parseInt(reader.readLine().trim()); StringTokenizer tokenizer = new StringTokenizer(reader.readLine()); int[] heights = new int[n]; for (int j = 0; j < n; j++) { heights[j] = Integer.parseInt(tokenizer.nextToken()); } cases.add(heights); } for (int i = 0; i < numCases; i++) { int operations = 0; int[] heights = cases.get(i); int n = heights.length; if (n != 1) { for (int j = 0; j < n-1; j++) { if (heights[j] > heights[j + 1]) { heights[j+1] = heights[j]; operations++; } } } System.out.println(operations); } } }
2031A
wrong_submission
291,589,592
Java 21
WRONG_ANSWER on test 2
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); for(int i = 0;i<n;i++){ int w = input.nextInt(); int [] arr = new int [w]; for(int j = 0;j<w;j++){ arr[j] = input.nextInt(); } int counter=0; for(int j =0 ;j<w;j++){ for(int k = 0;k<w;k++){ if(arr[j]!=arr[k]){ counter++; } } } counter = counter/w; System.out.println(counter); } } }
2031A
wrong_submission
291,603,842
Java 21
WRONG_ANSWER on test 2
import java.util.*; public class Penchick { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int testCase =sc.nextInt(); for(int z=0;z<testCase;z++){ int size = sc.nextInt(); int count=0; int a = sc.nextInt(); for(int i=1;i<size;i++){ int b=sc.nextInt(); if(a>b){ count++; } a=b; } System.out.println(count); } sc.close(); } }
2031A
wrong_submission
291,624,063
Java 8
WRONG_ANSWER on test 2
import java.util.Scanner; public class file { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); for (int tc = 0; tc < t; tc++) { int n = scanner.nextInt(); int[] heights = new int[n]; for (int i = 0; i < n; i++) { heights[i] = scanner.nextInt(); } int operations = 0; for (int i = 1; i < n; i++) { if (heights[i] < heights[i - 1]) { heights[i] = heights[i - 1]; operations++; } } System.out.println(operations); } scanner.close(); } }
2031A
wrong_submission
291,655,257
Java 21
WRONG_ANSWER on test 2
// Online Java Compiler // Use this editor to write, compile and run your Java code online import java.util.*; public class a { 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 steps= 0; for(int j=1;j<n;j++) { if(arr[j]<arr[j-1]) { arr[j]=arr[j-1]; steps++; } } System.out.print(steps+" "); t--; } } }
2031A
wrong_submission
291,614,578
Java 21
WRONG_ANSWER on test 2
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); int[] h = new int[n]; for (int i = 0; i < n; i++) { h[i] = sc.nextInt(); } int c = 0; for (int i = 1; i < n; i++) { if (h[i] < h[i - 1]) { c++; h[i] = h[i - 1]; } } System.out.println(c); } sc.close(); } }
2031A
wrong_submission
291,585,565
PyPy 3-64
WRONG_ANSWER on test 2
for i in range(int(input())): n=int(input()) l=list(map(int,input().split())) c=0 for i in range(n-1): if l[i]>l[i+1]: if((i+1)!=(n-1)): l[i+1]=max(l[i],l[i+2]) c+=1 print(c)
2031A
wrong_submission
291,728,258
PyPy 3-64
WRONG_ANSWER on test 2
from typing import List from bisect import * from collections import * from itertools import * from math import * from functools import * from string import * from heapq import * from random import randint from types import * from sys import * setrecursionlimit(100000) M = 10**9 + 7 SALT = randint(1, 10**9) for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) res = 0 for i in range(1, n): res += a[i] < a[i-1] print(res)
2031A
wrong_submission
291,641,507
Java 21
WRONG_ANSWER on test 2
import java.util.*; public class Sample { public static void main(String[] args)throws Exception { 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 k=n/2; if(n==1) { System.out.println("0"); continue; } int c=0; for(int i=0;i<k;i++) { if(a[i]>a[k]) { c++; } } for(int i=k+1;i<n;i++) { if(a[i]<a[k]) { c++; } } System.out.println(c); } } }
2031A
wrong_submission
291,577,892
PyPy 3-64
WRONG_ANSWER on test 2
t = int(input()) for _ in range(t): n = int(input()) c = list(map(int, input().split())) s = 0 for i in range(1, n): if c[i] != c[i - 1]: s += 1 print(s)
2031A
wrong_submission
291,618,027
PyPy 3-64
WRONG_ANSWER on test 2
t=int(input()) for _ in range(t): n=int(input()) arr=list(map(int,input().split())) print(len(list(set(arr)))-1)
2031A
wrong_submission
292,975,751
PyPy 3-64
WRONG_ANSWER on test 2
def solve(): n = int(input()) h = list(map(int, input().split())) min = 0 for i in range(n): if i+1 < n: if h[i] > h[i+1]: min += 1 print(min) t = int(input()) for _ in range(t): solve()
2031A
wrong_submission
291,636,584
PyPy 3-64
WRONG_ANSWER on test 2
t = int(input()) for _ in range(t): n = int(input()) l = list(map(int, input().split())) a = 0 l2 = [] if n == 1: print(0) else: for i in l: l2.append(l.count(i)) m = max(l2) if m <= 2: print(n-m) else: print(min(m, n-m))
2031A
wrong_submission
291,616,526
PyPy 3-64
WRONG_ANSWER on test 2
import sys from heapq import * from bisect import bisect_left, bisect_right from os import path from math import sqrt, gcd, factorial, log from io import BytesIO, IOBase from collections import defaultdict, Counter, deque BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") # sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) # input = lambda: sys.stdin.readline().rstrip("\r\n") # sys.setrecursionlimit(4000) # if sys.version_info[0] < 3: # sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout) # else: # sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") mod = int(1e9) + 7 MOD = 998244353 def lcm(a,b): return (a*b)//(gcd(a%b,b)) if a*b != 0 else a+b def mex(l): n = max(l) m = (n+1)*[0] for i in l : m[i] = 1 for i in range(n+1) : if m[i] == 0 : return i return n+1 def exp(a,b): ans = 1 while b : if b&1 : ans *= a ans %= mod a *= a b >>= 1 return ans def SieveOfEratosthenes(n): a = [True for i in range(n+1)] p = 2 while (p * p <= n): if (a[p] == True): for i in range(p * p, n+1, p): a[i] = False p += 1 return a # ***************** Be careful with the use of 1 and 0 while using log ***************** def solve(test): n = int(input()) # n,k = map(int,input().split()) a = list(map(int,input().split())) l = [a[0]] for i in range(1,n): l.append(max(a[i], l[-1])) # print(l) ans = 0 for i in range(n) : ans += (l[i] != a[i]) print(ans) def main(): if path.exists("D:/Academics/Competetive_Programming/Programs/Python/input.txt"): sys.stdin = open("D:/Academics/Competetive_Programming/Programs/Python/input.txt", 'r') sys.stdout = open("D:/Academics/Competetive_Programming/Programs/Python/output.txt", 'w') test = 1 for test in range(int(input())): solve(test) # solve(test) if __name__ == '__main__': main()
2031A
wrong_submission
291,579,859
PyPy 3-64
WRONG_ANSWER on test 2
for _ in range(int(input())): n = int(input()) h = list(map(int,input().split())) re = 0 for i in range(1,n): if h[i]<h[i-1]: re+=1 print(re)
2031A
wrong_submission
291,598,509
Java 21
WRONG_ANSWER on test 2
import java.io.*; import java.util.*; public class CF { static class FastIO { BufferedReader br; StringTokenizer st; public FastIO() { br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(""); } String next() { while (!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() { try { return br.readLine(); } catch (IOException e) { e.printStackTrace(); } return null; } void print(Object o) { System.out.print(o); } void println(Object o) { System.out.println(o); } void printArray(int[] arr) { for (int i = 0; i < arr.length; i++) { System.out.print(arr[i] + " "); } System.out.println(); } } static PrintWriter out = new PrintWriter(System.out); public static void main(String[] args) throws IOException { FastIO io = new FastIO(); int t = io.nextInt(); while (t-- > 0) { solve(io); } out.close(); } public static void solve(FastIO io) { int n = io.nextInt(); int[] arr = new int[n]; int[] arr2=new int[n]; for(int i=0;i<n;i++) { arr[i]=io.nextInt(); arr2[i]=arr[i]; } int cnt=0; for(int i=n-1;i>0;i--) { if(arr[i]<arr[i-1]) { cnt=n-i;; } } io.println(cnt); } }
2031A
wrong_submission
291,586,612
Java 21
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(); for (int i = 0; i < t; i++) { int n = sc.nextInt(); int[] arr = new int[n]; for (int j = 0;j < n; j++){ arr[j] = sc.nextInt(); } helper(arr, n); } } public static void helper(int[] arr, int n) { int count = 0; for (int i = 0;i < n-1; i++) { if (arr[i] > arr[i+1]) count++; } System.out.println(count); } }
2031A
wrong_submission
291,793,685
PyPy 3-64
WRONG_ANSWER on test 2
def solve(): n = int(input()) height = list(map(int, input().split())) ans = 0 for i in range(1,n): if height[i-1]>height[i]: ans+=1 print(ans) t = int(input()) for i in range(0,t): solve()
2031A
wrong_submission
291,606,830
Java 8
WRONG_ANSWER on test 2
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class PenchickAndModern { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringTokenizer t = new StringTokenizer(in.readLine()); int test = Integer.parseInt(t.nextToken()); while (test-- > 0) { t = new StringTokenizer(in.readLine()); int n = Integer.parseInt(t.nextToken()); int[] a = new int[n]; t = new StringTokenizer(in.readLine()); for (int i = 0; i < n; i++) a[i] = Integer.parseInt(t.nextToken()); int prev = a[0]; int c = 0; for (int i = 1; i < n; i++) { if (a[i] != prev) { if (i < n - 1 && a[i] == a[i + 1]) { a[i - 1] = a[i] - 1; prev = a[i]; c++; } else { a[i] = prev + 1; prev = a[i]; c++; } } } out.println(c); } out.close(); } }
2031A
wrong_submission
291,682,155
Java 21
WRONG_ANSWER on test 2
/****************************************************************************** Online Java Compiler. Code, Compile, Run and Debug java program online. Write your code in this editor and press "Run" button to execute it. *******************************************************************************/ import java.util.*; public class q63 { 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<arr.length;i++){ arr[i]=sc.nextInt(); } if(n==1){ System.out.println(0); }else{ HashSet<Integer>set=new HashSet<>(); for(int i=0;i<arr.length;i++){ set.add(arr[i]); } if(set.size()==n){ System.out.println(n-1); }else{ System.out.println(n-set.size()); } } } } }
2031A
wrong_submission
291,601,931
PyPy 3-64
WRONG_ANSWER on test 2
from collections import Counter def split_segments(arr): res, seg = [], [] for n in arr: if not seg or n >= seg[-1]: seg.append(n) else: res.append(seg) seg = [n] if seg: res.append(seg) return res for _ in range(int(input())): n = int(input()) heights = list(map(int, input().split())) count = 0 for seg in split_segments(heights): count += 1 print(count - 1)
2031A
wrong_submission
291,585,673
PyPy 3-64
WRONG_ANSWER on test 2
for _ in range(int(input())): n = int(input()) h = list(map(int, input().split())) count = 0 for i in range(1, n): if h[i-1] > h[i]: h[i] = h[i-1] count += 1 print(count)
2031A
wrong_submission
291,600,936
PyPy 3-64
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,638,888
Java 21
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[] h = new int[n]; for (int i = 0; i < n; i++) { h[i] = sc.nextInt(); } int operations = calculateMinimumOperations(h, n); System.out.println(operations); } sc.close(); } private static int calculateMinimumOperations(int[] h, int n) { int operations = 0; int[] result = new int[n]; result[0] = h[0]; for (int i = 1; i < n; i++) { if (h[i] < result[i - 1]) { result[i] = result[i - 1]; operations++; } else { result[i] = h[i]; } } return operations; } }
2031A
wrong_submission
291,604,001
Java 21
WRONG_ANSWER on test 2
import java.util.Scanner; public class penchick{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t,n; t=sc.nextInt(); for(int i=0;i<t;i++){ n=sc.nextInt(); int[] arr=new int[n]; int maxct=1; int currct=1; for(int j=0;j<n;j++){ arr[j]=sc.nextInt(); } for(int j=0;j<n;j++){ for(int k=j+1;k<n;k++){ if(arr[j]==arr[k]){ currct++; if(currct>maxct){ maxct=currct; } } } currct=0; } System.out.println(n-maxct); } sc.close(); } }
2031A
wrong_submission
291,610,286
Java 21
WRONG_ANSWER on test 2
import java.util.Scanner; public class Main{ public static int minOperations(int[] h) { int operations = 0; int prev = h[0]; for (int i = 1; i < h.length; i++) { if (h[i] > prev) { continue; } operations += prev - h[i]; prev = h[i]; } return operations; } public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); for (int i = 0; i < t; i++) { int n = scanner.nextInt(); int[] h = new int[n]; for (int j = 0; j < n; j++) { h[j] = scanner.nextInt(); } int result = minOperations(h); System.out.println(result); } } }
2031A
wrong_submission
291,595,293
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); int t,z,i,n,l,c,opr; t=sc.nextInt(); for(z=1;z<=t;z++) { n=sc.nextInt(); int h[]=new int[n]; for(i=0;i<n;i++) h[i]=sc.nextInt(); l=h[0]; c=0; for(i=0;i<n;i++) { if(h[i]==l) c++; else break; } opr=n-c; System.out.println(opr); } } }
2031A
wrong_submission
293,658,173
PyPy 3-64
WRONG_ANSWER on test 2
from math import ceil, floor ii = lambda: int(input()) il = lambda: list(map(int, input().split())) isc = lambda: list(input()) for _ in range(ii()): n = ii() arr = il() d = 0 for i in range(n - 1): if arr[i] == arr[i+1]: d += 1 print(n - 1 - d)
2031A
wrong_submission
291,639,886
PyPy 3-64
WRONG_ANSWER on test 2
results=[] def funn(n,li): count=0 if len(li)==1: count=0 return count else: for j in range(n-1): if li[j+1]<li[j]: count +=1 li[j+1]=li[j] return count t=int(input()) for i in range(t): n=int(input()) li=list(map(int,input().split())) results.append(funn(n,li)) for r in results: print(r)
2031A
wrong_submission
291,601,428
PyPy 3-64
WRONG_ANSWER on test 2
import collections import random def solve(): n = int(input()) rand = random.randint(0, 10000) list_h = list(map(int, input().split())) list_h = [str(h + rand) for h in list_h] counter = collections.Counter(list_h) unique_values = sorted(counter.keys(), reverse=True, key=lambda x: int(x)) cnt = 0 for ii in range(len(unique_values)-1): cnt += min(counter[unique_values[ii]], counter[unique_values[ii+1]]) print(cnt) for _ in range(int(input())): solve()
2031A
wrong_submission
291,591,843
PyPy 3-64
WRONG_ANSWER on test 2
def problem2031A() -> int: n = int(input()) h = list(map(int, input().split(' '))) left = 0 right = 0 for h_i in h: if h_i == h[0]: left += 1 if h_i == h[-1]: right += 1 return min(n - left, n - right) test_cases = int(input()) for _ in range(test_cases): print(problem2031A())
2031A
wrong_submission
291,602,726
Java 21
WRONG_ANSWER on test 2
import java.util.*; import java.io.*; public class test { static Scanner sc = new Scanner(System.in); static PrintWriter pw = new PrintWriter(System.out); static final int mod = 1000000007; //----------------------------------------------------------------------------- public static void main (String[] args ) throws IOException { div(); pw.flush(); } //----------------------------------------------------------------------------- public static void div() throws IOException { int t = 1; t = sc.nextInt(); a : while (t-- > 0) { int n = sc.nextInt(); int ans = 0 , ele = sc.nextInt(); for (int i = 1; i < n; i++) { int j = sc.nextInt(); if (j!=ele){ ele = j; ans++; } } pw.println(ans); } } //---------------Methods to use------------------------------------------------ //----------------------------------------------------------------------------- // Class : Scanner static class Scanner { StringTokenizer st; BufferedReader br; public Scanner(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); } public Scanner(String file) throws IOException { br = new BufferedReader(new FileReader(file)); } public Scanner(FileReader r) { br = new BufferedReader(r); } public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public String readAllLines(BufferedReader reader) throws IOException { StringBuilder content = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { content.append(line); content.append(System.lineSeparator()); } return content.toString(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public String nextLine() throws IOException { return br.readLine(); } public double nextDouble() throws IOException { String x = next(); StringBuilder sb = new StringBuilder("0"); double res = 0, f = 1; boolean dec = false, neg = false; int start = 0; if (x.charAt(0) == '-') { neg = true; start++; } for (int i = start; i < x.length(); i++) if (x.charAt(i) == '.') { res = Long.parseLong(sb.toString()); sb = new StringBuilder("0"); dec = true; } else { sb.append(x.charAt(i)); if (dec) f *= 10; } res += Long.parseLong(sb.toString()) / f; return res * (neg ? -1 : 1); } public long[] nextLongArray(int n) throws IOException { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } public Long[] nextlongArray(int n) throws IOException { Long[] a = new Long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } public int[] nextIntArray(int n) throws IOException { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public Integer[] nextIntegerArray(int n) throws IOException { Integer[] a = new Integer[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public boolean ready() throws IOException { return br.ready(); } } }
2031A
wrong_submission
300,546,064
PyPy 3-64
WRONG_ANSWER on test 2
import statistics ran = int(input()) for _ in range(ran): n = int(input()) l = list(map(int,input().split())) mdn = statistics.median(l) c = 0 for i in l: if (abs(mdn-i)!=0): c += 1 print(c)
2031A
wrong_submission
291,665,138
Java 8
WRONG_ANSWER on test 2
// package extra; import java.util.*; public class hbhb { 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 ans = 0; for(int i = 1; i < n; i++) { if(arr[i] < arr[i-1]) ans++; } System.out.println(ans); } } }
2031A
wrong_submission
297,654,330
Java 21
WRONG_ANSWER on test 2
import java.util.Scanner; public class Penchick_and_Modern_Monument { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int i = 0; i < n; i++) { int t = sc.nextInt(); int[] k = new int[t]; for (int l = 0; l < k.length; l++) { k[l] = sc.nextInt(); } int count = 0; for (int m = 0; m < k.length - 1; m++) { for (int j = 0; j < k.length - i - 1; j++) { if (k[m] > k[m + 1]) { int temp = k[m]; k[m] = k[m + 1]; k[m + 1] = temp; count++; } } } System.out.println(count); } } }
2031A
wrong_submission
291,737,233
Java 8
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(); 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=1;i<n;i++){ if(a[i]!=a[i-1]){ ans++; } } System.out.println(ans); } //System.out.println("Hello World"); } }
2031A
wrong_submission
291,593,814
PyPy 3-64
WRONG_ANSWER on test 2
for _ in range(int(input())): n=int(input()) arr=list(map(int,input().split())) c=0 for i in range(n-1): if arr[i]>arr[i+1]: c+=1 arr[i+1]=arr[i] print(c)
2031A
wrong_submission
291,619,487
Java 21
WRONG_ANSWER on test 2
// Source: https://usaco.guide/general/io import java.io.*; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); int t = Integer.parseInt(f.readLine()); while (t-- > 0) { int n = Integer.parseInt(f.readLine()); StringTokenizer st = new StringTokenizer(f.readLine()); int[] arr = new int[n]; for (int i = 0; i < n; i++) arr[i] = Integer.parseInt(st.nextToken()); int x = arr[0]; int ans = 0; for (int i = 1; i < n; i++){ if (arr[i] != x) { ans = n - i; break; } } x = arr[n - 1]; for (int i = n - 1; i >= 0; i--) { if (arr[i] != x) { ans = Math.min(ans, i + 1); break; } } System.out.println(ans); } out.close(); } }
2031A
wrong_submission
296,029,929
PyPy 3-64
WRONG_ANSWER on test 2
for i in range(int(input())): a=int(input()) l=list(map(int,input().split())) count = 0 for i in range(a - 1): if l[i] > l[i + 1]: count += 1 print(count)
2031A
wrong_submission
291,662,494
PyPy 3-64
WRONG_ANSWER on test 2
import sys, threading import math from os import path from collections import deque, defaultdict, Counter from bisect import * from string import ascii_lowercase from functools import cmp_to_key from random import randint from heapq import * from array import array from types import GeneratorType def readInts(): x = list(map(int, (sys.stdin.readline().rstrip().split()))) return x[0] if len(x) == 1 else x def readList(type=int): x = sys.stdin.readline() x = list(map(type, x.rstrip('\n\r').split())) return x def readStr(): x = sys.stdin.readline().rstrip('\r\n') return x write = sys.stdout.write read = sys.stdin.readline MAXN = 1123456 def bootstrap(f, stack=[]): def wrappedfunc(*args, **kwargs): if stack: return f(*args, **kwargs) else: to = f(*args, **kwargs) while True: if type(to) is GeneratorType: stack.append(to) to = next(to) else: stack.pop() if not stack: break to = stack[-1].send(to) return to return wrappedfunc class mydict: def __init__(self, func=lambda: 0): self.random = randint(0, 1 << 32) self.default = func self.dict = {} def __getitem__(self, key): mykey = self.random ^ key if mykey not in self.dict: self.dict[mykey] = self.default() return self.dict[mykey] def get(self, key, default): mykey = self.random ^ key if mykey not in self.dict: return default return self.dict[mykey] def __setitem__(self, key, item): mykey = self.random ^ key self.dict[mykey] = item def getkeys(self): return [self.random ^ i for i in self.dict] def __str__(self): return f'{[(self.random ^ i, self.dict[i]) for i in self.dict]}' def lcm(a, b): return (a*b)//(math.gcd(a,b)) def mod(n): return n%(1000000007) def solve(t): # print(f'Case #{t}: ', end = '') n = readInts() ar = readList() ans = n for i in range(n): if ar[i] == ar[0]: ans -= 1 else: break print(ans) def main(): t = 1 if path.exists("/Users/arijitbhaumik/Library/Application Support/Sublime Text/Packages/User/input.txt"): sys.stdin = open("/Users/arijitbhaumik/Library/Application Support/Sublime Text/Packages/User/input.txt", 'r') sys.stdout = open("/Users/arijitbhaumik/Library/Application Support/Sublime Text/Packages/User/output.txt", 'w') # sys.setrecursionlimit(100000) t = readInts() for i in range(t): solve(i+1) if __name__ == '__main__': main()
2031A
wrong_submission
291,577,202
Java 21
WRONG_ANSWER on test 2
/* Author: WORTH Problem: Penchick and Modern Monument */ // Solution at end import java.util.*; import java.io.*; import java.util.function.*; public class Main { static ContestScanner sc = new ContestScanner(); static FastWriter out = new FastWriter(); public static void main(String[] args) throws Exception { // sc = new ContestScanner(new File("input.txt")); // out = new FastWriter("output.txt"); boolean debug = args.length > 0 && args[0].equals("-DEBUG"); if (debug) { out.println("New Sample:"); boolean append = args.length > 1; System.setErr(new PrintStream(new FileOutputStream("D:\\Codes\\CPRelatedFiles\\error.txt", append), true)); } Thread t = new Thread(null, new ActualSolution(sc, out, debug), "actual_solution", 256 << 20); t.setUncaughtExceptionHandler(($, e) -> { try { out.flush(); throw e; } catch (NoSuchElementException fine) { System.exit(0); } catch (Throwable issue) { issue.printStackTrace(System.err); System.exit(1); } }); t.start(); t.join(); out.flush(); if (debug) main(new String[]{"-DEBUG", "Again"}); } } /** * @see <a href = "https://github.com/NASU41/AtCoderLibraryForJava/blob/master/ContestIO/ContestScanner.java">Source code by NASU41 (Slightly Modified)</a> */ class ContestScanner { private static final long LONG_MAX_TENTHS = 922337203685477580L; private static final int LONG_MAX_LAST_DIGIT = 7; private static final int LONG_MIN_LAST_DIGIT = 8; private final InputStream in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; public ContestScanner(InputStream in) { this.in = in; } public ContestScanner(File file) throws FileNotFoundException { this(new BufferedInputStream(new FileInputStream(file))); } public ContestScanner() { this(System.in); } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private boolean hasNextByte() { if (ptr < buflen) return true; ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } return buflen > 0; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } public boolean hasNext() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public String nextLine() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b) || b == ' ') { sb.appendCodePoint(b); b = readByte(); } return sb.toString().trim(); } public String[] nextStringArray(int length) { String[] array = new String[length]; for (int i = 0; i < length; i++) array[i] = this.next(); return array; } public String[] nextStringArray(int length, UnaryOperator<String> map) { String[] array = new String[length]; for (int i = 0; i < length; i++) array[i] = map.apply(this.next()); return array; } public String[][] nextStringMatrix(int height, int width) { String[][] mat = new String[height][width]; for (int h = 0; h < height; h++) { for (int w = 0; w < width; w++) { mat[h][w] = this.next(); } } return mat; } public String[][] nextStringMatrix(int height, int width, UnaryOperator<String> map) { String[][] mat = new String[height][width]; for (int h = 0; h < height; h++) { for (int w = 0; w < width; w++) { mat[h][w] = map.apply(this.next()); } } return mat; } public char[][] nextCharMatrix(int height, int width) { char[][] mat = new char[height][width]; for (int h = 0; h < height; h++) { String s = this.next(); for (int w = 0; w < width; w++) { mat[h][w] = s.charAt(w); } } return mat; } public char[][] nextCharMatrix(int height, int width, UnaryOperator<Character> map) { char[][] mat = new char[height][width]; for (int h = 0; h < height; h++) { String s = this.next(); for (int w = 0; w < width; w++) { mat[h][w] = map.apply(s.charAt(w)); } } return mat; } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public int[] nextIntArray(int length) { int[] array = new int[length]; for (int i = 0; i < length; i++) array[i] = this.nextInt(); return array; } public int[] nextIntArray(int length, IntUnaryOperator map) { int[] array = new int[length]; for (int i = 0; i < length; i++) array[i] = map.applyAsInt(this.nextInt()); return array; } public int[][] nextIntMatrix(int height, int width) { int[][] mat = new int[height][width]; for (int h = 0; h < height; h++) for (int w = 0; w < width; w++) { mat[h][w] = this.nextInt(); } return mat; } public int[][] nextIntMatrix(int height, int width, IntUnaryOperator map) { int[][] mat = new int[height][width]; for (int h = 0; h < height; h++) for (int w = 0; w < width; w++) { mat[h][w] = map.applyAsInt(this.nextInt()); } return mat; } public Integer[] nextIntegerArray(int length) { Integer[] array = new Integer[length]; for (int i = 0; i < length; i++) array[i] = this.nextInt(); return array; } public Integer[] nextIntegerArray(int length, IntUnaryOperator map) { Integer[] array = new Integer[length]; for (int i = 0; i < length; i++) array[i] = map.applyAsInt(this.nextInt()); return array; } public Integer[][] nextIntegerMatrix(int height, int width) { Integer[][] mat = new Integer[height][width]; for (int h = 0; h < height; h++) for (int w = 0; w < width; w++) { mat[h][w] = this.nextInt(); } return mat; } public Integer[][] nextIntegerMatrix(int height, int width, IntUnaryOperator map) { Integer[][] mat = new Integer[height][width]; for (int h = 0; h < height; h++) for (int w = 0; w < width; w++) { mat[h][w] = map.applyAsInt(this.nextInt()); } return mat; } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { int digit = b - '0'; if (n >= LONG_MAX_TENTHS) { if (n == LONG_MAX_TENTHS) { if (minus) { if (digit <= LONG_MIN_LAST_DIGIT) { n = -n * 10 - digit; b = readByte(); if (!isPrintableChar(b)) { return n; } else if (b < '0' || '9' < b) { throw new NumberFormatException(String.format("%d%s... is not number", n, Character.toString(b))); } } } else { if (digit <= LONG_MAX_LAST_DIGIT) { n = n * 10 + digit; b = readByte(); if (!isPrintableChar(b)) { return n; } else if (b < '0' || '9' < b) { throw new NumberFormatException(String.format("%d%s... is not number", n, Character.toString(b))); } } } } throw new ArithmeticException(String.format("%s%d%d... overflows long.", minus ? "-" : "", n, digit)); } n = n * 10 + digit; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } public long[] nextLongArray(int length) { long[] array = new long[length]; for (int i = 0; i < length; i++) array[i] = this.nextLong(); return array; } public long[] nextLongArray(int length, LongUnaryOperator map) { long[] array = new long[length]; for (int i = 0; i < length; i++) array[i] = map.applyAsLong(this.nextLong()); return array; } public long[][] nextLongMatrix(int height, int width) { long[][] mat = new long[height][width]; for (int h = 0; h < height; h++) for (int w = 0; w < width; w++) { mat[h][w] = this.nextLong(); } return mat; } public long[][] nextLongMatrix(int height, int width, LongUnaryOperator map) { long[][] mat = new long[height][width]; for (int h = 0; h < height; h++) for (int w = 0; w < width; w++) { mat[h][w] = map.applyAsLong(this.nextLong()); } return mat; } public Long[] nextLongWrapperArray(int length) { Long[] array = new Long[length]; for (int i = 0; i < length; i++) array[i] = this.nextLong(); return array; } public Long[] nextLongWrapperArray(int length, LongUnaryOperator map) { Long[] array = new Long[length]; for (int i = 0; i < length; i++) array[i] = map.applyAsLong(this.nextLong()); return array; } public Long[][] nextLongWrapperMatrix(int height, int width) { Long[][] mat = new Long[height][width]; for (int h = 0; h < height; h++) for (int w = 0; w < width; w++) { mat[h][w] = this.nextLong(); } return mat; } public Long[][] nextLongWrapperMatrix(int height, int width, LongUnaryOperator map) { Long[][] mat = new Long[height][width]; for (int h = 0; h < height; h++) for (int w = 0; w < width; w++) { mat[h][w] = map.applyAsLong(this.nextLong()); } return mat; } public double nextDouble() { return Double.parseDouble(next()); } public double[] nextDoubleArray(int length) { double[] array = new double[length]; for (int i = 0; i < length; i++) array[i] = this.nextDouble(); return array; } public double[] nextDoubleArray(int length, DoubleUnaryOperator map) { double[] array = new double[length]; for (int i = 0; i < length; i++) array[i] = map.applyAsDouble(this.nextDouble()); return array; } public double[][] nextDoubleMatrix(int height, int width) { double[][] mat = new double[height][width]; for (int h = 0; h < height; h++) for (int w = 0; w < width; w++) { mat[h][w] = this.nextDouble(); } return mat; } public double[][] nextDoubleMatrix(int height, int width, DoubleUnaryOperator map) { double[][] mat = new double[height][width]; for (int h = 0; h < height; h++) for (int w = 0; w < width; w++) { mat[h][w] = map.applyAsDouble(this.nextDouble()); } return mat; } } /** * @see <a href = "https://codeforces.com/profile/uwi">Source code by uwi (Slightly Modified)</a> */ class FastWriter { private static final int BUF_SIZE = 1 << 13; private final byte[] buf = new byte[BUF_SIZE]; private final OutputStream out; private int ptr = 0; public FastWriter() { this(System.out); } public FastWriter(OutputStream os) { this.out = os; } public FastWriter(String path) { try { this.out = new FileOutputStream(path); } catch (FileNotFoundException e) { throw new RuntimeException(path + " not found!"); } } private static int countDigits(int l) { if (l >= 1000000000) return 10; if (l >= 100000000) return 9; if (l >= 10000000) return 8; if (l >= 1000000) return 7; if (l >= 100000) return 6; if (l >= 10000) return 5; if (l >= 1000) return 4; if (l >= 100) return 3; if (l >= 10) return 2; return 1; } private static int countDigits(long l) { if (l >= 1000000000000000000L) return 19; if (l >= 100000000000000000L) return 18; if (l >= 10000000000000000L) return 17; if (l >= 1000000000000000L) return 16; if (l >= 100000000000000L) return 15; if (l >= 10000000000000L) return 14; if (l >= 1000000000000L) return 13; if (l >= 100000000000L) return 12; if (l >= 10000000000L) return 11; if (l >= 1000000000L) return 10; if (l >= 100000000L) return 9; if (l >= 10000000L) return 8; if (l >= 1000000L) return 7; if (l >= 100000L) return 6; if (l >= 10000L) return 5; if (l >= 1000L) return 4; if (l >= 100L) return 3; if (l >= 10L) return 2; return 1; } private void innerFlush() { try { out.write(buf, 0, ptr); ptr = 0; } catch (IOException e) { throw new RuntimeException("inner flush"); } } public void flush() { innerFlush(); try { out.flush(); } catch (IOException e) { throw new RuntimeException("flush"); } } public FastWriter print(byte b) { buf[ptr++] = b; if (ptr == BUF_SIZE) innerFlush(); return this; } public FastWriter print(char c) { return print((byte) c); } public FastWriter print(String s) { s.chars().forEach(c -> { buf[ptr++] = (byte) c; if (ptr == BUF_SIZE) innerFlush(); }); return this; } public FastWriter print(int x) { if (x == Integer.MIN_VALUE) { return print((long) x); } if (ptr + 12 >= BUF_SIZE) innerFlush(); if (x < 0) { print((byte) '-'); x = -x; } int d = countDigits(x); for (int i = ptr + d - 1; i >= ptr; i--) { buf[i] = (byte) ('0' + x % 10); x /= 10; } ptr += d; return this; } public FastWriter print(long x) { if (x == Long.MIN_VALUE) { return print(String.valueOf(x)); } if (ptr + 21 >= BUF_SIZE) innerFlush(); if (x < 0) { print((byte) '-'); x = -x; } int d = countDigits(x); for (int i = ptr + d - 1; i >= ptr; i--) { buf[i] = (byte) ('0' + x % 10); x /= 10; } ptr += d; return this; } public FastWriter print(double x, int precision) { if (x < 0) { print('-'); x = -x; } x += Math.pow(10, -precision) / 2; // if(x < 0){ x = 0; } print((long) x).print("."); x -= (long) x; for (int i = 0; i < precision; i++) { x *= 10; print((char) ('0' + (int) x)); x -= (int) x; } return this; } public FastWriter print(double x) { return print(x, 20); } public FastWriter print(Object x) { return print(x.toString()); } public FastWriter println() { return print((byte) '\n'); } public FastWriter println(char c) { return print(c).println(); } public FastWriter println(int x) { return print(x).println(); } public FastWriter println(long x) { return print(x).println(); } public FastWriter println(double x, int precision) { return print(x, precision).println(); } public FastWriter println(double x) { return println(x, 20); } public FastWriter println(String s) { return print(s).println(); } public FastWriter println(Object x) { return println(x.toString()); } public void printArray(char[] array, String separator) { int n = array.length; if (n == 0) { println(); return; } for (int i = 0; i < n - 1; i++) { print(array[i]); print(separator); } println(array[n - 1]); } public void printArray(char[] array) { this.printArray(array, " "); } public void printArray(char[] array, String separator, java.util.function.UnaryOperator<Character> map) { int n = array.length; if (n == 0) { println(); return; } for (int i = 0; i < n - 1; i++) { print(map.apply(array[i])); print(separator); } println(map.apply(array[n - 1])); } public void printArray(char[] array, java.util.function.UnaryOperator<Character> map) { this.printArray(array, " ", map); } public void printArray(int[] array, String separator) { int n = array.length; if (n == 0) { println(); return; } for (int i = 0; i < n - 1; i++) { print(array[i]); print(separator); } println(array[n - 1]); } public void printArray(int[] array) { this.printArray(array, " "); } public void printArray(int[] array, String separator, java.util.function.IntUnaryOperator map) { int n = array.length; if (n == 0) { println(); return; } for (int i = 0; i < n - 1; i++) { print(map.applyAsInt(array[i])); print(separator); } println(map.applyAsInt(array[n - 1])); } public void printArray(int[] array, java.util.function.IntUnaryOperator map) { this.printArray(array, " ", map); } public void printArray(long[] array, String separator) { int n = array.length; if (n == 0) { println(); return; } for (int i = 0; i < n - 1; i++) { print(array[i]); print(separator); } println(array[n - 1]); } public void printArray(long[] array) { this.printArray(array, " "); } public void printArray(long[] array, String separator, java.util.function.LongUnaryOperator map) { int n = array.length; if (n == 0) { println(); return; } for (int i = 0; i < n - 1; i++) { print(map.applyAsLong(array[i])); print(separator); } println(map.applyAsLong(array[n - 1])); } public void printArray(long[] array, java.util.function.LongUnaryOperator map) { this.printArray(array, " ", map); } public void printArray(double[] array, String separator) { int n = array.length; if (n == 0) { println(); return; } for (int i = 0; i < n - 1; i++) { print(array[i]); print(separator); } println(array[n - 1]); } public void printArray(double[] array) { this.printArray(array, " "); } public void printArray(double[] array, String separator, java.util.function.DoubleUnaryOperator map) { int n = array.length; if (n == 0) { println(); return; } for (int i = 0; i < n - 1; i++) { print(map.applyAsDouble(array[i])); print(separator); } println(map.applyAsDouble(array[n - 1])); } public void printArray(double[] array, java.util.function.DoubleUnaryOperator map) { this.printArray(array, " ", map); } public <T> void printArray(T[] array, String separator) { int n = array.length; if (n == 0) { println(); return; } for (int i = 0; i < n - 1; i++) { print(array[i]); print(separator); } println(array[n - 1]); } public <T> void printArray(T[] array) { this.printArray(array, " "); } public <T> void printArray(T[] array, String separator, java.util.function.UnaryOperator<T> map) { int n = array.length; if (n == 0) { println(); return; } for (int i = 0; i < n - 1; i++) { print(map.apply(array[i])); print(separator); } println(map.apply(array[n - 1])); } public <T> void printArray(T[] array, java.util.function.UnaryOperator<T> map) { this.printArray(array, " ", map); } public <T> void printCollection(Collection<T> collection, String separator) { boolean first = true; for (T c : collection) { if (!first) print(separator); first = false; print(c); } println(); } public <T> void printCollection(Collection<T> collection) { this.printCollection(collection, " "); } public <T> void printCollection(Collection<T> collection, String separator, java.util.function.UnaryOperator<T> map) { boolean first = true; for (T c : collection) { if (!first) print(separator); first = false; print(map.apply(c)); } println(); } public <T> void printCollection(Collection<T> collection, java.util.function.UnaryOperator<T> map) { this.printCollection(collection, " ", map); } } class ActualSolution implements Runnable { boolean debug; ContestScanner sc; FastWriter out; public ActualSolution(ContestScanner sc, FastWriter out, boolean debug) { this.sc = sc; this.out = out; this.debug = debug; } @SuppressWarnings("unchecked") <T> String debugIt(T t) { if (t == null) return "null"; try { return debugIt((Iterable<T>) t); } catch (ClassCastException e) { if (t instanceof int[]) return Arrays.toString((int[]) t); else if (t instanceof long[]) return Arrays.toString((long[]) t); else if (t instanceof char[]) return Arrays.toString((char[]) t); else if (t instanceof float[]) return Arrays.toString((float[]) t); else if (t instanceof double[]) return Arrays.toString((double[]) t); else if (t instanceof boolean[]) return Arrays.toString((boolean[]) t); try { return debugIt((Object[]) t); } catch (ClassCastException e1) { return t.toString(); } } } <T> String debugIt(T[] arr) { StringBuilder ret = new StringBuilder("["); boolean first = true; for (T t : arr) { if (!first) ret.append(", "); first = false; ret.append(debugIt(t)); } return ret.append("]").toString(); } <T> String debugIt(Iterable<T> it) { StringBuilder ret = new StringBuilder("["); boolean first = true; for (T t : it) { if (!first) ret.append(", "); first = false; ret.append(debugIt(t)); } return ret.append("]").toString(); } void debug(Object... obj) { if (!debug) return; System.err.print("#" + Thread.currentThread().getStackTrace()[2].getLineNumber() + ": "); for (Object x : obj) System.err.print(debugIt(x) + " "); System.err.println(); } @Override public void run() { int testCases = sc.nextInt(); for (int testCase = 1; testCase <= testCases; testCase++) { debug("......"); debug("Test case ", testCase); //out.print("Case #"); //out.print(testCase); //out.print(": "); solve(); } } void solve() { int n = sc.nextInt(); int[] h = sc.nextIntArray(n); int ans = n - 1; for (int i = 0; i < n - 1; i++) { if (h[i] == h[i + 1]) ans--; } out.println(ans); } }
2031A
wrong_submission
291,624,690
PyPy 3-64
WRONG_ANSWER on test 2
class Solution: def operation(self,n:int,h:list)->int: ans=0 c={} for i in h: if i in c: c[i]+=1 else: c[i]=1 life=max(c) for i in h: if i!=life: ans+=1 return ans if __name__=="__main__": pointer=Solution() result=[] t=int(input()) for _ in range(t): n=int(input()) h=list(map(int,input().split(" "))) result.append(pointer.operation(n,h)) for i in result: print(i)
2031A
wrong_submission
291,606,525
Java 21
WRONG_ANSWER on test 2
import java.util.*; public class A_Penchick_and_Modern_Monument { public static void main(String[] args) { Scanner s = new Scanner(System.in); int T=s.nextInt(); for(int i=1; i<=T; i++){ int n = s.nextInt(); int[] h = new int[n]; int cnt=0; int same=0; int pura=0; int finall=0; for(int j=0; j<n; j++){ h[j] = s.nextInt(); } for(int j=1; j<n; j++){ if(h[j]<h[j-1]){ cnt++; if(same>finall){ finall = same; } same=0; }else if(h[j]==h[j-1]){ same++; } } if(cnt==n-1){ System.out.println(n-1); }else if(cnt!=n-1 && cnt<=2){ System.out.println(cnt); }else { System.out.println(n-1-finall); } } } }
2031A
wrong_submission
291,763,086
PyPy 3-64
WRONG_ANSWER on test 2
from functools import * from itertools import * from collections import * from math import * from bisect import * from heapq import * def factors(n): i = 1 res = [] while i <= sqrt(n): if (n % i == 0): if (n / i == i): res.append(i) else: res.append(i) res.append(n//i) i = i + 1 return res def prime_factors(n): i = 2 factors = [] while i * i <= n: if n % i: i += 1 else: n //= i factors.append(i) if n > 1: factors.append(n) return factors def largest_prime_factor(n): i = 2 while i * i <= n: if n % i: i += 1 else: n //= i return n def sieve(n): prime = [True for i in range(n+1)] p = 2 while (p * p <= n): if (prime[p] == True): for i in range(p * p, n+1, p): prime[i] = False p += 1 return prime MOD=10**9+7 class Factorial: def __init__(self, MOD): self.MOD = MOD self.factorials = [1, 1] self.invModulos = [0, 1] self.invFactorial_ = [1, 1] def calc(self, n): if n <= -1: print("Invalid argument to calculate n!") print("n must be non-negative value. But the argument was " + str(n)) exit() if n < len(self.factorials): return self.factorials[n] nextArr = [0] * (n + 1 - len(self.factorials)) initialI = len(self.factorials) prev = self.factorials[-1] m = self.MOD for i in range(initialI, n + 1): prev = nextArr[i - initialI] = prev * i % m self.factorials += nextArr return self.factorials[n] def inv(self, n): if n <= -1: print("Invalid argument to calculate n^(-1)") print("n must be non-negative value. But the argument was " + str(n)) exit() p = self.MOD pi = n % p if pi < len(self.invModulos): return self.invModulos[pi] nextArr = [0] * (n + 1 - len(self.invModulos)) initialI = len(self.invModulos) for i in range(initialI, min(p, n + 1)): next = -self.invModulos[p % i] * (p // i) % p self.invModulos.append(next) return self.invModulos[pi] def invFactorial(self, n): if n <= -1: print("Invalid argument to calculate (n^(-1))!") print("n must be non-negative value. But the argument was " + str(n)) exit() if n < len(self.invFactorial_): return self.invFactorial_[n] self.inv(n) # To make sure already calculated n^-1 nextArr = [0] * (n + 1 - len(self.invFactorial_)) initialI = len(self.invFactorial_) prev = self.invFactorial_[-1] p = self.MOD for i in range(initialI, n + 1): prev = nextArr[i - initialI] = (prev * self.invModulos[i % p]) % p self.invFactorial_ += nextArr return self.invFactorial_[n] class Combination: def __init__(self, MOD): self.MOD = MOD self.factorial = Factorial(MOD) def ncr(self, n, k): if k < 0 or n < k: return 0 k = min(k, n - k) f = self.factorial return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) @lru_cache(None) def dp(idx): if idx>=n-1:return 0 res = inf if arr[idx]>arr[idx+1]: if arr[idx+1]-1>0: t = arr[idx] arr[idx] = arr[idx+1]-1 res = min(res, 1+dp(idx+1)) arr[idx] = t t = arr[idx+1] arr[idx+1] = arr[idx]+1 res = min(res, 1+dp(idx+1)) arr[idx+1] = t return res return dp(idx+1) print(dp(0))
2031A
wrong_submission
292,080,466
PyPy 3-64
WRONG_ANSWER on test 2
t=int(input()) while t>0: t-=1 n=int(input()) lst=list(map(int,input().split())) result=n-1 if n!=1: for i in range(0,n-1): if lst[i]==lst[i+1]: result-=1 print(result)
2031A
wrong_submission
291,586,822
Java 21
WRONG_ANSWER on test 2
import java.util.*; import java.lang.*; import java.io.*; public class Codechef { private static void solve(Scanner sc) { int n = sc.nextInt(); if (n == 1) { System.out.println(0); return; } int[] arr = new int[n]; for (int i = 0; i < n; i++) arr[i] = sc.nextInt(); Arrays.sort(arr); int max = Integer.MIN_VALUE; int c = 1; for (int i = 1; i < n; i++) { if (arr[i] != arr[i - 1]) { max = Math.max(max, c); c = 1; } else c++; } max = Math.max(max, c); System.out.println(n - max); } public static void main(String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); long t = sc.nextLong(); sc.nextLine(); while (t-- > 0) solve(sc); sc.close(); } private static boolean indexCheck(int i, int j, int n) { return i >= 0 && i < n && j >= 0 && j < n; } private static long[] prefixSum(int[] arr) { long[] array = new long[arr.length]; long sum = 0; for (int i = 0; i < arr.length; i++) { sum += arr[i]; array[i] = sum; } return array; } public 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; } public static int sumOfDigits(int n) { int sum = 0; while (n > 0) { int mod = n % 10; sum += mod; n /= 10; } return sum; } public static boolean isPrime(int n) { if (n == 1) return false; if (n == 2 || 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 nextPrime(int n) { while (!isPrime(n)) n++; return n; } public static boolean isBinSorted(String s) { int max = Character.getNumericValue(s.charAt(0)); for (int i = 1; i < s.length(); i++) { int curr = Character.getNumericValue(s.charAt(i)); if (curr >= max) { max = curr; } else return false; } return true; } public static int gcd(int a, int b) { while (b != 0) { int temp = b; b = a % b; a = temp; } return a; } public static int lcm(int a, int b) { return Math.abs(a * b) / gcd(a, b); } }
2031A
wrong_submission
294,314,227
PyPy 3-64
WRONG_ANSWER on test 2
a = int(input()) lis = [] for i in range(a): store = int(input()) b = list(map(int,input().split())) lis.append(b) for i in lis: req = i[0] re = len(i) for k in i: if(k == req): re -= 1 print(re)
2031A
wrong_submission
291,644,126
PyPy 3
WRONG_ANSWER on test 2
t=int(input()) l=[] while(t!=0): t=t-1 n=int(input()) h=[] m=input().split(" ") for i in m: h.append(int(i)) k=[] k.extend(h) c=0 for i in range(n-1): if h[i]==h[i+1]: c=c+1 l.append(n-(c+1)) for i in l: print(i)
2031A
wrong_submission
291,652,367
PyPy 3
WRONG_ANSWER on test 2
for _ in range(int(input())): N = int(input()) H = list(map(int, input().split())) if N == 1: print(0) continue T = H[:] ans = 0 a = b = 0 for i in range(N-1): if H[i] <= H[i+1]: continue H[i+1] = H[i] a += 1 for i in range(N-1): if T[-i-1] >= T[-i-2]: continue T[-i-2] = T[-i-1] b += 1 ans = min(a, b) print(ans)
2031A
wrong_submission
291,588,772
PyPy 3-64
WRONG_ANSWER on test 2
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) cnt = 0 expected = 1 for i in arr: if i < expected: cnt += 1 else: expected = i print(cnt)
2031A
wrong_submission
291,651,032
PyPy 3
WRONG_ANSWER on test 2
import sys # from io import StringIO def main(): input = sys.stdin.read data = input().splitlines() index = 0 t = int(data[index]) index += 1 for _ in range(t): n = int(data[index]) index += 1 heights = list(map(int, data[index].split())) index += 1 maxHeight = max(heights) steps = 0 for i in range(n): if heights[i] < maxHeight: steps += 1 sys.stdout.write("{}\n".format(steps)) if __name__ == "__main__": # test_input = """3 # 5 # 5 4 3 2 1 # 3 # 2 2 1 # 1 # 1 # """ # sys.stdin = StringIO(test_input) main()
2031A
wrong_submission
296,380,537
PyPy 3-64
WRONG_ANSWER on test 2
# PyRival PyPy3 Fast IO import math import os import sys from io import BytesIO, IOBase def main(): pass BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._file = file self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)) self.newlines = b.count(b"\n") + (not b) ptr = self.buffer.tell() self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd, self.buffer.getvalue()) self.buffer.truncate(0), self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self, file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s: self.buffer.write(s.encode("ascii")) self.read = lambda: self.buffer.read().decode("ascii") self.readline = lambda: self.buffer.readline().decode("ascii") sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout) input = lambda: sys.stdin.readline().rstrip("\r\n") # endregion def pillar(arr,n): if len(arr)==len(set(arr)): return n-1 return len(arr)-len(set(arr)) if __name__ == "__main__": main() for _ in range(int(input())): n=int(input()) arr=list(map(int,input().split())) print(pillar(arr,n))
2031A
wrong_submission
304,215,755
PyPy 3-64
WRONG_ANSWER on test 2
t = int(input()) for _ in range(t): n = int(input()) lst = list(map(int, input().split())) ans = 0 for i in range(1,n): if lst[i] < lst[i-1]: ans += 1 print(ans)
2031A
wrong_submission
291,832,844
PyPy 3-64
WRONG_ANSWER on test 2
for _ in range(int(input())): n = int(input()) heights = list(map(int, input().split())) def find(n , arr): freqCnt = 0 prev = -1 maxFreq = 1 for i in range(n): if arr[i] == prev: freqCnt += 1 else: maxFreq = max(maxFreq, freqCnt); freqCnt = 1; prev = arr[i] return maxFreq print(n - find(n, heights))
2031A
wrong_submission
291,584,072
PyPy 3-64
WRONG_ANSWER on test 2
t = int(input()) for _ in range(t): h = int(input()) l = list(map(int,input().split())) countr = 0 for i in range(h-1): if l[i] > l[i+1]: countr += 1 print(countr)
2031A
wrong_submission
291,677,286
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; int v[n]; int k=0; for(int i=0;i<n;i++){cin>>v[i];} int count=1; int res=1; for(int i=0;i<n;i++){ if(v[i]==v[i+1]){count++;} else{res=max(res,count);count=1;} } cout<<n-res<<endl; } }
2031A
wrong_submission
291,618,513
PyPy 3-64
TIME_LIMIT_EXCEEDED on test 2
import sys from math import inf input = lambda: sys.stdin.readline().rstrip() def solve(): n = int(input()) a = list(map(int, input().split())) ans = inf def dfs(i, total): if i == n - 1: nonlocal ans ans = min(ans, total) return for k in range(1, n + 1): tmp = a[i] a[i] = k if a[i] <= a[i + 1]: dfs(i + 1, total + (0 if tmp == k else 1)) a[i] = tmp dfs(0, 0) print(ans) for _ in range(int(input())): solve()
2031A
wrong_submission
295,972,764
PyPy 3-64
WRONG_ANSWER on test 2
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) s = 0 for i in range(1, n): if a[i] < a[i - 1]: s += 1 a[i] = a[i - 1] print(s)
2031A
wrong_submission
291,601,088
PyPy 3-64
WRONG_ANSWER on test 2
def min_operations_to_non_decreasing(t, test_cases): results = [] for case in test_cases: n, heights = case operations = 0 for i in range(n - 1): if heights[i] > heights[i + 1]: operations += 1 heights[i + 1] = heights[i] results.append(operations) return results # Reading input from the system import sys input = sys.stdin.read data = input().split() t = int(data[0]) index = 1 test_cases = [] for _ in range(t): n = int(data[index]) heights = list(map(int, data[index + 1:index + 1 + n])) test_cases.append((n, heights)) index += n + 1 results = min_operations_to_non_decreasing(t, test_cases) for result in results: print(result)
2031A
wrong_submission