π
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# μ λ ₯ λ°κΈ° | |
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 μΈλ±μ€λ‘ μ²λ¦¬ν΄μ£ΌκΈ° μν΄ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# νμ΄μ¬ λΉ λ₯Έ μ λ ₯ μ¬μ© | |
import sys | |
input = sys.stdin.readline | |
# μ λ ₯ λ°κΈ° | |
n, m = map(int, input().split()) | |
a = list(map(int, input().split())) | |
# ꡬκ°ν© λ°°μ΄ λ§λ€κΈ°, κΈΈμ΄λ n + 1 κ°λ‘ λ§λ€μ΄μ£Όλ©΄ λλ€(μλ λ°°μ΄μ κΈΈμ΄ + 1). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input()) | |
arr = list(map(int, input().split())) | |
m = int(input()) | |
# κ·Έλ₯ λͺ¨λ μ€ μ μλ μ§ κ²μ¬ | |
S = sum(arr) | |
if m >= S: | |
print(max(arr)) | |
exit(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input()) | |
arr = list(map(int, input().split())) | |
m = int(input()) | |
# κ·Έλ₯ λͺ¨λ μ€ μ μλ μ§ κ²μ¬ | |
S = sum(arr) | |
if m >= S: | |
print(max(arr)) | |
exit(0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Scanner; | |
class Pair { | |
int x, y; | |
Pair(int a, int b) { | |
this.x = a; | |
this.y = b; | |
} |