Skip to content

Commit

Permalink
プログラミングコンテスト攻略のためのアルゴリズムとデータ構造の問題
Browse files Browse the repository at this point in the history
  • Loading branch information
Kazuki Miyasaka authored and Kazuki Miyasaka committed Jun 5, 2019
0 parents commit f096c9e
Show file tree
Hide file tree
Showing 1,206 changed files with 17,084 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added AizuOnlineJudge/.DS_Store
Binary file not shown.
Binary file not shown.
52 changes: 52 additions & 0 deletions AizuOnlineJudge/1.MaximumProfit/Answer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include<iostream>
//#include <algorithm>
using namespace std;

static const int MAX = 200000;

int main() {
int R[MAX]; //価格の配列
int n; //時刻数

//入力
cin >> n;
for (int i = 0; i < n; i++) {
cin >> R[i];
}

//計算
int maxv = -2000000000; //十分小さい値を初期値に設定
int minv = R[0];

for (int i = 1; i < n; i++) {
maxv = max(maxv, R[i] - minv);
minv = min(minv, R[i]);
}

//出力
cout << maxv << endl;

return 0;
}

int max(int oldMax, int newMax) {
int nowMax;

nowMax = oldMax;
if (newMax > oldMax) {
nowMax = newMax;
}

return nowMax;
}

int min(int oldMin, int newMin) {
int nowMin;

nowMin = oldMin;
if (newMin > oldMin) {
nowMin = newMin;
}

return nowMin;
}
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions AizuOnlineJudge/1.MaximumProfit/Debug/MaximumProfit.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
 Mysolve.cpp
MaximumProfit.vcxproj -> C:\VisualStudio\AizuOnlineJudge\MaximumProfit\Debug\MaximumProfit.exe
MaximumProfit.vcxproj -> C:\VisualStudio\AizuOnlineJudge\MaximumProfit\Debug\MaximumProfit.pdb (Full PDB)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
Debug|Win32|C:\VisualStudio\AizuOnlineJudge\MaximumProfit\|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added AizuOnlineJudge/1.MaximumProfit/Debug/Mysolve.obj
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
28 changes: 28 additions & 0 deletions AizuOnlineJudge/1.MaximumProfit/MaximumProfit.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MaximumProfit", "MaximumProfit.vcxproj", "{CBD7AD16-3F55-44EC-9BFE-5FAC94AF56E2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CBD7AD16-3F55-44EC-9BFE-5FAC94AF56E2}.Debug|x64.ActiveCfg = Debug|x64
{CBD7AD16-3F55-44EC-9BFE-5FAC94AF56E2}.Debug|x64.Build.0 = Debug|x64
{CBD7AD16-3F55-44EC-9BFE-5FAC94AF56E2}.Debug|x86.ActiveCfg = Debug|Win32
{CBD7AD16-3F55-44EC-9BFE-5FAC94AF56E2}.Debug|x86.Build.0 = Debug|Win32
{CBD7AD16-3F55-44EC-9BFE-5FAC94AF56E2}.Release|x64.ActiveCfg = Release|x64
{CBD7AD16-3F55-44EC-9BFE-5FAC94AF56E2}.Release|x64.Build.0 = Release|x64
{CBD7AD16-3F55-44EC-9BFE-5FAC94AF56E2}.Release|x86.ActiveCfg = Release|Win32
{CBD7AD16-3F55-44EC-9BFE-5FAC94AF56E2}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
155 changes: 155 additions & 0 deletions AizuOnlineJudge/1.MaximumProfit/MaximumProfit.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{CBD7AD16-3F55-44EC-9BFE-5FAC94AF56E2}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>MaximumProfit</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Answer.cpp" />
<ClCompile Include="Mysolve.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
25 changes: 25 additions & 0 deletions AizuOnlineJudge/1.MaximumProfit/MaximumProfit.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="ソース ファイル">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="ヘッダー ファイル">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="リソース ファイル">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Mysolve.cpp">
<Filter>ソース ファイル</Filter>
</ClCompile>
<ClCompile Include="Answer.cpp">
<Filter>ソース ファイル</Filter>
</ClCompile>
</ItemGroup>
</Project>
33 changes: 33 additions & 0 deletions AizuOnlineJudge/1.MaximumProfit/Mysolve.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include<stdio.h>
#include<math.h>

static const int Rt_MAX = 100000;

int main() {
int n; //時刻数
int Rt[Rt_MAX]; //価格
int max; //最大利益
int min; //最小価格

//入力
scanf_s("%d", &n);
for (int i = 0; i < n; i++) {
scanf_s("%d", &Rt[i]);
}

//計算
max = -2000000000;
min = Rt[0];
//+1からスタート
for (int i = 1; i < n; i++) {
if (Rt[i] - min > max) {
max = Rt[i] - min;
}
if (Rt[i] < min) {
min = Rt[i];
}
}

printf_s("%d\n", max);
return 0;
}
Binary file not shown.
Binary file added AizuOnlineJudge/10.STLstack/10.STLstack.VC.db
Binary file not shown.
28 changes: 28 additions & 0 deletions AizuOnlineJudge/10.STLstack/10.STLstack.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "10.STLstack", "10.STLstack.vcxproj", "{D73D5097-0321-4879-B4DD-8A42147D33DE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D73D5097-0321-4879-B4DD-8A42147D33DE}.Debug|x64.ActiveCfg = Debug|x64
{D73D5097-0321-4879-B4DD-8A42147D33DE}.Debug|x64.Build.0 = Debug|x64
{D73D5097-0321-4879-B4DD-8A42147D33DE}.Debug|x86.ActiveCfg = Debug|Win32
{D73D5097-0321-4879-B4DD-8A42147D33DE}.Debug|x86.Build.0 = Debug|Win32
{D73D5097-0321-4879-B4DD-8A42147D33DE}.Release|x64.ActiveCfg = Release|x64
{D73D5097-0321-4879-B4DD-8A42147D33DE}.Release|x64.Build.0 = Release|x64
{D73D5097-0321-4879-B4DD-8A42147D33DE}.Release|x86.ActiveCfg = Release|Win32
{D73D5097-0321-4879-B4DD-8A42147D33DE}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Loading

0 comments on commit f096c9e

Please sign in to comment.