consolidate all repos to one for archive
This commit is contained in:
31
semester_5/aturp/naloga_1/main.cpp
Normal file
31
semester_5/aturp/naloga_1/main.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
std::ifstream inputFile(argv[1]);
|
||||
|
||||
int boxSize, goldSize, goldValue, silverSize, silverValue;
|
||||
|
||||
while (inputFile >> boxSize >> goldSize >> goldValue >> silverSize >> silverValue)
|
||||
{
|
||||
int maxValue = 0;
|
||||
int goldCount = boxSize / goldSize;
|
||||
int silverCount = boxSize / silverSize;
|
||||
|
||||
for (size_t i = 0; i <= goldCount; i++)
|
||||
{
|
||||
for (size_t j = 0; j <= silverCount; j++)
|
||||
{
|
||||
if (i * goldSize + j * silverSize <= boxSize)
|
||||
{
|
||||
int value = i * goldValue + j * silverValue;
|
||||
maxValue = std::max(maxValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%d\n", maxValue);
|
||||
}
|
||||
inputFile.close();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user