Challenge
Careers
Class
Connect
로그인 후 문제풀이가 가능합니다.
질문에 있는 모든 반례를 다 넣었는데 잘 나오거든요.. 틀린 이유를 진짜 못찾겠어요 반례좀 부탁드려요.
import java.io.*; import java.util.*; public class Main { static int N; static int arr[]; static int count[][]; //각 인덱스에 돌 개수 최댓값을 넣어줌 (count[각 돌의 인덱스][넘어가는 순서에, 더 작은 돌이 생기게 되면, 카운트를 다시 세기] static int answer[]; //각 돌을 시작으로 뛰었을 때의 돌 개수 최댓값 static int answerMax = 1; //최종 정답 public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokeniz...
오답, 반례 문의
안녕하세요 파이썬으로 아래와 같이 코드를 작성했는데, 오답이라고 나오네요 반례가 있을까요? 어디가 잘못된 건지도 함께 알려주시면 감사하겠습니다. import sys n = input() row = input().split() row_int = [] for i in row: row_int.append(int(i)) max = 0 count = 0 for i in row_int: if i > max: count += 1 max = i print(count)
반례 부탁드립니다.
질문 글에 있는 반례들은 다 돌려봤는데 아직 반례를 못찾겠습니다.. 알려주시면 감사드리겠습니다. import sys stack, max = 0, 0 _ = int(input()) height = list(map(int, input().split())) ans = [] for h in height: ans.append([h]) for a in ans: if h > a[-1]: a.append(h) elif len(a) >= 2 and h < a[-1] and h > a[-2]: a.pop() a.append(h) ans.sort(key=len, reverse=True) print(len(ans[0]))
징검다리 반례 부탁 드립니다!
복잡도를 줄이려고 A[i]와 A[i+1]을 비교해서 A[i+1]이 큰 경우가 연속되는 케이스를 카운트 하는 방식으로 했는데, 무엇이 문제인지 모르겠습니다ㅠㅠ import sys N = int(sys.stdin.readline()) A = list(map(int, sys.stdin.readline().split())) if N != 1: ans = list(range(N-1)) for i in range(N-1): if (A[i] - A[i+1] < 0): ans[i] = True else: ans[i] = False steps = 1 answer = 1 found = False for i in range(len(ans)): if ans[i]: steps += 1 found = True else: steps = 1 continue answer = steps if steps > answer else answer print(answer if found else 0) else: pri...
해당 케이스의 반례는 무엇이며 어떻게 tc를 넣길래 전부 오답처리가 되는지요??
import sys def solution(s, t): result = [] for i in range(s): current_result = [t[i]] for j in range(i + 1, s): if t[j] > current_result[-1]: current_result.append(t[j]) result.append(current_result) max_length = max(len(sublist) for sublist in result) return max_length
뭐가 문제라 오답이 나오는 걸까요?
import sys n = int(input()) a = list(map(int, input().split())) dpL = [1]*n for i in range(1, n): tmpL = [] for j in range(i): if a[i] > a[j]: tmpL.append((j, a[j])) if(len(tmpL) != 0): sortedL = sorted(tmpL, key = lambda x : x[1], reverse = True) dpL[i] = dpL[i] + dpL[sortedL[0][0]] print(max(dpL))
징검다리 반례 부탁드립니다
import java.io.*; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int loop = Integer.parseInt(br.readLine()); int[] stones = new int[loop]; StringTokenizer st = new StringTokenizer(br.readLine()); for (int i = 0; i < loop; i++) { stones[i] = Integer.parseInt(st.nextToken()); ...
징검다리 반례 부탁드립니다!
import sys from itertools import permutations n=int(sys.stdin.readline()) A=list(map(int,sys.stdin.readline().split())) count=0 def check(p): print(p) cnt=0 com=0 for i in range(len(p)): if com com=p[i] cnt+=1 print(cnt) return cnt for i in range(n): count=max(count,check(A)) A.pop(0) print(count)
징검다리1 반례좀 찾아주세요
여러번의 시도 끝에 제대로 된 코드는 이거다! 하고 작성한거 같은데 오답이네요..ㅠㅠ 반례 좀 알려주세요.... #include #include int sol(int num, int arr[]); int main(void) { int N=0; scanf("%d", &N); int* A=(int*)malloc(sizeof(int) * N); for(int i=0;iarr[j]){ if (max_value
징검다리 문제 왜 오답이 나오는지 잘 모르겠습니다!
s = list(map(int, input().split())) k = 0 a = [] for i, j in enumerate(s) : if k < j : a.append(i) k = j print(len(a)) 상기 코드로도 답은 똑같이 나오는데 오답 처리가 되는 사유를 모르겠습니다