Skip to content

Instantly share code, notes, and snippets.

View mym0404's full-sized avatar
πŸ”Š
Loud your code

MJ Studio mym0404

πŸ”Š
Loud your code
View GitHub Profile
t = int(input())
while t:
t -= 1
answer = -10 ** 9
n = int(input())
a = list(map(int, input().split()))
psum = [0 for _ in range(n + 1)]
for i in range(n):
# μž…λ ₯ λ°›κΈ°
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(1, n):
a[i] += a[i - 1]
for i in range(m):
l, r = map(int, input().split())
# 0-based 인덱슀둜 μ²˜λ¦¬ν•΄μ£ΌκΈ° μœ„ν•΄
# 파이썬 λΉ λ₯Έ μž…λ ₯ μ‚¬μš©
import sys
input = sys.stdin.readline
# μž…λ ₯ λ°›κΈ°
n, m = map(int, input().split())
a = list(map(int, input().split()))
# ꡬ간합 λ°°μ—΄ λ§Œλ“€κΈ°, κΈΈμ΄λŠ” n + 1 개둜 λ§Œλ“€μ–΄μ£Όλ©΄ λœλ‹€(μ›λž˜ λ°°μ—΄μ˜ 길이 + 1).
N, C = map(int, input().split())
Pos = [int(input()) for _ in range(N)]
Pos.sort()
left, right = 1, 10 ** 9
answer = -1
while left <= right:
n = int(input())
arr = list(map(int, input().split()))
m = int(input())
# κ·Έλƒ₯ λͺ¨λ‘ 쀄 수 μžˆλŠ” μ§€ 검사
S = sum(arr)
if m >= S:
print(max(arr))
exit(0)
n = int(input())
arr = list(map(int, input().split()))
m = int(input())
# κ·Έλƒ₯ λͺ¨λ‘ 쀄 수 μžˆλŠ” μ§€ 검사
S = sum(arr)
if m >= S:
print(max(arr))
exit(0)
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
vector<int> arr{1, 2, 3, 3, 5, 6, 6, 8, 9, 10};
int left = 0, right = arr.size() - 1, target = 8;
int answer = lower_bound(arr.begin(), arr.end(), target) - arr.begin();
cout << answer;
from bisect import bisect_left
arr = [1, 2, 3, 3, 5, 6, 6, 8, 9, 10]
left, right = 0, 9
target = 8
answer = bisect_left(arr, target, lo=left, hi=right)
arr = [1, 2, 3, 3, 5, 6, 6, 8, 9, 10]
left, right = 0, 9
target = 8
answer = -1
while left <= right:
mid = (left + right) // 2
if arr[mid] >= target:
import java.util.ArrayList;
import java.util.Scanner;
class Pair {
int x, y;
Pair(int a, int b) {
this.x = a;
this.y = b;
}