Skip to content

Commit de3b1be

Browse files
author
Eric
committed
Merge remote-tracking branch 'upstream/main'
2 parents 07d1aec + c47c02a commit de3b1be

13 files changed

Lines changed: 199 additions & 0 deletions

File tree

.github/workflows/merge-and-generate-problems.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ jobs:
6969
7070
LIVE_GROUP=$(((NEXT_TEST - 1) / 10))
7171
72+
echo "NEXT_TEST=test$NEXT_TEST"
73+
echo "LIVE_FOLDER=live$LIVE_GROUP"
74+
7275
echo "NEXT_TEST=test$NEXT_TEST" >> $GITHUB_ENV
7376
echo "LIVE_FOLDER=live$LIVE_GROUP" >> $GITHUB_ENV
7477
@@ -79,6 +82,7 @@ jobs:
7982
touch $LIVE_FOLDER/$NEXT_TEST/문제1/.gitkeep
8083
touch $LIVE_FOLDER/$NEXT_TEST/문제2/.gitkeep
8184
touch $LIVE_FOLDER/$NEXT_TEST/문제3/.gitkeep
85+
echo "✅ Created folder: $LIVE_FOLDER/$NEXT_TEST"
8286
8387
- name: Commit and Push Changes
8488
if: env.pr_found == 'true'

live0/test4/문제1/.gitkeep

Whitespace-only changes.

live0/test4/문제2/.gitkeep

Whitespace-only changes.

live0/test4/문제3/.gitkeep

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import sys
2+
3+
input = sys.stdin.readline
4+
5+
n = int(input())
6+
graph = [list(map(int, input().split())) for _ in range(n)]
7+
8+
9+
for k in range(n):
10+
for i in range(n):
11+
for j in range(n):
12+
if graph[i][k] == 1 and graph[k][j] == 1:
13+
graph[i][j] = 1
14+
15+
for row in graph:
16+
print(*row)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def main():
2+
N = int(input())
3+
A = [list(map(int, input().split())) for _ in range(N)]
4+
5+
for i in range(N):
6+
for j in range(N):
7+
for k in range(N):
8+
if A[j][i] and A[i][k]:
9+
A[j][k] = 1
10+
11+
for num in A:
12+
print(' '.join(map(str, num)))
13+
14+
15+
if __name__ == "__main__":
16+
main()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const input = require("fs")
2+
.readFileSync(
3+
process.platform === "linux"
4+
? "/dev/stdin"
5+
: require("path").join(__dirname, "input.txt"),
6+
"utf8"
7+
)
8+
.toString()
9+
.trim()
10+
.split("\n")
11+
.map((line) => line.split(" ").map(Number));
12+
13+
function solution(input) {
14+
const N = input[0][0];
15+
const G = input.slice(1);
16+
17+
for (let k = 0; k < N; k++)
18+
for (let i = 0; i < N; i++)
19+
for (let j = 0; j < N; j++) if (G[i][k] && G[k][j]) G[i][j] = 1;
20+
21+
return G.map((row) => row.join(" ")).join("\n");
22+
}
23+
24+
console.log(solution(input));
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
"""
2+
dp[0] = -1
3+
dp[1] = -1
4+
dp[2] = -1
5+
dp[3] = 1
6+
dp[4] = -1
7+
dp[5] = 1
8+
dp[6] = 2
9+
dp[7] = -1
10+
dp[8] = 1(5) + 1(3) = 2 // dp[5] + dp[3]
11+
dp[9] = 3 // dp[3] * 3
12+
dp[10] = 2 // dp[5] * 2
13+
dp[11] = 1 + 2 // dp[5] + dp[6]
14+
dp[12] = 4 // dp[6] * 2
15+
dp[13] = // dp[3] + dp[10]
16+
dp[14] // dp[5] + dp[9]
17+
dp[15] = 3 // dp[5] * 3
18+
dp[16] = -1 // dp[5] + dp[11]
19+
dp[17] = -1 // dp[5] + dp[12]
20+
dp[18] = 3 + 1 = 4 // dp[3] + dp[15]
21+
22+
"""
23+
24+
import sys
25+
26+
input = sys.stdin.readline
27+
28+
n = int(input())
29+
30+
dp = [-1] * 50001
31+
dp[3] = 1
32+
dp[5] = 1
33+
dp[6] = 2
34+
35+
for i in range(8, n + 1):
36+
if dp[i - 3] != -1:
37+
dp[i] = dp[i - 3] + 1
38+
if dp[i - 5] != -1:
39+
dp[i] = dp[i - 5] + 1
40+
# 3, 5kg로 나눌 수 있다면
41+
if dp[i - 3] > 0 and dp[i - 5] > 0:
42+
dp[i] = min(dp[i - 3], dp[i - 5]) + 1
43+
44+
print(dp[n])
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
def main():
2+
N = int(input())
3+
4+
dp = [float('inf')] * (N + 1)
5+
dp[0] = 0
6+
7+
for i in range(1, N+1):
8+
if i >= 3 and dp[i - 3] != float('inf'):
9+
dp[i] = min(dp[i], dp[i - 3] + 1)
10+
if i >= 5 and dp[i - 5] != float('inf'):
11+
dp[i] = min(dp[i], dp[i - 5] + 1)
12+
13+
if dp[N] == float('inf'):
14+
dp[N] = -1
15+
16+
print(dp[N])
17+
18+
19+
if __name__ == "__main__":
20+
main()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
const filePath =
5+
process.platform === "linux"
6+
? "/dev/stdin"
7+
: path.join(__dirname, "input.txt");
8+
9+
const input = fs.readFileSync(filePath, "utf8").toString().trim();
10+
11+
function solution(input) {
12+
const sugar = input;
13+
let [bag3, bag5] = [0, 0];
14+
bag5 = Math.floor(sugar / 5);
15+
bag3 = (sugar - bag5 * 5) / 3;
16+
17+
while (bag5 >= 0) {
18+
if (bag3 === Math.floor(bag3)) return bag5 + bag3;
19+
20+
if (bag3 % 3 !== 0) {
21+
--bag5;
22+
bag3 = (sugar - bag5 * 5) / 3;
23+
}
24+
}
25+
return -1;
26+
}
27+
28+
console.log(solution(input));

0 commit comments

Comments
 (0)