first commit
This commit is contained in:
commit
31bda4481f
37 changed files with 4645 additions and 0 deletions
28
2024/one/one-2.lua
Normal file
28
2024/one/one-2.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
a = {}
|
||||
b = {}
|
||||
s = {}
|
||||
n = 1000
|
||||
r = 0
|
||||
|
||||
for i=1,n*2 do
|
||||
if i % 2 == 1 then
|
||||
table.insert(a, io.read("*n"))
|
||||
else
|
||||
table.insert(b, io.read("*n"))
|
||||
end
|
||||
end
|
||||
|
||||
table.sort(a)
|
||||
table.sort(b)
|
||||
|
||||
for i=1, n do
|
||||
ap = 0
|
||||
for j=1, n do
|
||||
if a[i] == b[j] then
|
||||
ap = ap + 1
|
||||
end
|
||||
end
|
||||
r = r + ap*a[i]
|
||||
end
|
||||
|
||||
print(r)
|
7
2024/one/one.example
Normal file
7
2024/one/one.example
Normal file
|
@ -0,0 +1,7 @@
|
|||
3 4
|
||||
4 3
|
||||
2 5
|
||||
1 3
|
||||
3 9
|
||||
3 3
|
||||
|
1000
2024/one/one.input
Normal file
1000
2024/one/one.input
Normal file
File diff suppressed because it is too large
Load diff
21
2024/one/one.lua
Normal file
21
2024/one/one.lua
Normal file
|
@ -0,0 +1,21 @@
|
|||
a = {}
|
||||
b = {}
|
||||
s = 0
|
||||
n = 6
|
||||
|
||||
for i=1,n*2 do
|
||||
if i % 2 == 1 then
|
||||
table.insert(a, io.read("*n"))
|
||||
else
|
||||
table.insert(b, io.read("*n"))
|
||||
end
|
||||
end
|
||||
|
||||
table.sort(a)
|
||||
table.sort(b)
|
||||
|
||||
for i=1, n do
|
||||
s = s + math.abs(a[i] - b[i])
|
||||
end
|
||||
|
||||
print(s)
|
7
2024/two/two.example
Normal file
7
2024/two/two.example
Normal file
|
@ -0,0 +1,7 @@
|
|||
7 6 4 2 1
|
||||
1 2 7 8 9
|
||||
9 7 6 2 1
|
||||
1 3 2 4 5
|
||||
8 6 4 4 1
|
||||
1 3 6 7 9
|
||||
|
45
2024/two/two.lua
Normal file
45
2024/two/two.lua
Normal file
|
@ -0,0 +1,45 @@
|
|||
v = {}
|
||||
n = 6
|
||||
c = 0
|
||||
|
||||
for i = 1, n do
|
||||
z = {}
|
||||
for j = 1, 5 do
|
||||
table.insert(z, io.read("*n"))
|
||||
end
|
||||
v[i] = z
|
||||
end
|
||||
|
||||
for i = 1, n do
|
||||
ci = 0
|
||||
for j = 1, 4 do
|
||||
if math.abs(v[i][j] - v[i][j+1]) > 3 then
|
||||
ci = 1
|
||||
end
|
||||
end
|
||||
sort1 = v[i]
|
||||
table.sort(sort1)
|
||||
sort2 = v[i]
|
||||
table.sort(sort2, function(a,b) return a > b end)
|
||||
x = 0
|
||||
y = 0
|
||||
for j = 1,5 do
|
||||
if v[i][j] ~= sort1[j] then
|
||||
x = 1
|
||||
end
|
||||
if v[i][j] ~= sort2[j] then
|
||||
y = 1
|
||||
end
|
||||
end
|
||||
|
||||
if x == 1 or y == 1 then
|
||||
c1 = 1
|
||||
end
|
||||
|
||||
|
||||
if ci == 0 then
|
||||
c = c + 1
|
||||
end
|
||||
end
|
||||
|
||||
print(c)
|
Loading…
Add table
Add a link
Reference in a new issue