consolidate all repos to one for archive

This commit is contained in:
2025-01-28 13:46:42 +01:00
commit a6610fbc7a
5350 changed files with 2705721 additions and 0 deletions

View File

@@ -0,0 +1,95 @@
#include <iostream>
#include <vector>
#include <fstream>
std::vector<std::vector<int>> vec;
bool test(int num)
{
int prev = 0;
int count = 0;
for (size_t i = 0; i < vec.size(); i++)
{
for (size_t j = 0; j < vec[i].size(); j++)
{
if (vec[i][j] <= num)
continue;
if (count == 0)
{
prev = vec[i][j];
count++;
}
else if (count == 1)
{
if (prev != vec[i][j])
return false;
count = 0;
}
}
if (count > 0)
return false;
}
return true;
}
int alg(int start, bool s, int end, bool e)
{
if (end - start == 1)
{
if (s)
return start;
else if (e)
return end;
}
int middle = (start + end) / 2;
bool m = test(middle);
if (m == e)
{
return alg(start, s, middle, m);
}
else if (s == m)
{
return alg(middle, m, end, e);
}
return middle;
}
int start_alg(int num)
{
bool s = test(0);
bool e = test(num);
return alg(0, s, num, e);
}
int main(int argc, char const *argv[])
{
std::ifstream ifile(argv[1]);
int size = 0;
ifile >> size;
int num = 0;
int max = 0;
vec.emplace_back(std::vector<int>());
vec.emplace_back(std::vector<int>());
for (size_t i = 0; i < 2; i++)
{
for (size_t j = 0; j < size; j++)
{
ifile >> num;
if (num > max)
max = num;
vec[i].push_back(num);
}
}
int fin = start_alg(max);
std::cout << fin << "\n";
return 0;
}

View File

@@ -0,0 +1,27 @@
CC=g++
CFLAGS= -std=c++23
INCLUDE_DIR= include
SRC_DIR= src
# Get all cpp files from src directory
SRCS := $(wildcard $(SRC_DIR)/*.cpp)
all: main run
main: main.cpp $(SRCS)
$(CC) $(CFLAGS) -o3 -I$(INCLUDE_DIR) $(SRCS) main.cpp -o main
debug: main.cpp $(SRCS)
$(CC) $(CFLAGS) -I$(INCLUDE_DIR) $(SRCS) -g main.cpp -o main
run: main
./main testni_primer4.txt
zip:
zip -r main.zip main.cpp $(INCLUDE_DIR) $(SRC_DIR) makefile
clean:
rm main

View File

@@ -0,0 +1,4 @@
test 1: 2
test 2: 0
test 3: 999492
test 4: 999999579

View File

@@ -0,0 +1,3 @@
5
2 1 8 4 9
9 4 1 2 8

View File

@@ -0,0 +1,3 @@
8
7 7 15 15 2 2 4 4
5 5 3 3 9 9 1 1

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long