This commit is contained in:
Zengtudor 2023-10-05 23:07:15 +08:00
parent 89ea7a5350
commit 5dce88ec93
10 changed files with 178 additions and 3 deletions

4
.vscode/launch.json vendored
View File

@ -8,8 +8,8 @@
"args": [],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "/config/workspace/Luogu/P1540",
"program": "/config/workspace/Luogu/P1540/build/Debug/outDebug",
"cwd": "/config/workspace/Luogu/P3957",
"program": "/config/workspace/Luogu/P3957/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [

View File

@ -33,5 +33,6 @@
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false
"C_Cpp_Runner.useAddressSanitizer": false,
"cmake.sourceDirectory": "/config/workspace/Cpp/testHTTP/wfrest"
}

View File

@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}

24
Cpp/testHTTP/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "/config/workspace/Cpp/testHTTP/MyHttp",
"program": "/config/workspace/Cpp/testHTTP/MyHttp/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}

37
Cpp/testHTTP/.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,37 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wconversion",
"-Wnull-dereference",
"-Wsign-conversion"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false
}

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.22.1)
project(MyHttp)
set(CMAKE_CXX_STANDARD 20)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} wfrest workflow z)
set(CMAKE_INSTALL_RPATH /usr/local/lib)

BIN
Cpp/testHTTP/MyHttp/main Executable file

Binary file not shown.

View File

@ -0,0 +1,26 @@
/*
g++ -o main main.cpp -std=c++11 -lwfrest -lworkflow -lz -Wl,-rpath=/usr/local/lib
*/
#include "wfrest/HttpServer.h"
#include <cstdio>
#include <iostream>
#include <string>
#include <wfrest/HttpContent.h>
#include <wfrest/HttpMsg.h>
#include <workflow/URIParser.h>
using namespace wfrest;
int main(){
HttpServer sv;
sv.GET("/",[](const HttpReq *req,HttpResp *resp)->void{
});
if (sv.start(8888)==0) {
getchar();
sv.stop();
}else {
fprintf(stderr,"Cannot open port 8888 and start the server!!");
}
}

59
Luogu/P3957/P3957.cpp Normal file
View File

@ -0,0 +1,59 @@
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
struct _arrN{
int x,s;
};
const int MaxN = 5e5+5;
int n,d,k,f[MaxN];
_arrN arr[MaxN];
bool check(int);
int main(){
cin>>n>>d>>k;
for (int i=1; i<=n; i++) {
cin>>arr[i].x>>arr[i].s;
}
// cout<<check(1)<<endl;
int l=0,r=1e5,ans=-1;
while (l<=r) {
int mid = (l+r)/2;
if (check(mid)) {
ans=mid;
r=mid-1;
}else {
l=mid+1;
}
}
cout<<ans<<endl;
}
bool check(int g){
int lSet=max(0,d-g),rSet=d+g;
for (int i=1; i<sizeof(f)/sizeof(int); i++) {
f[i]=INT_MIN;
}
for (int i=1; i<=n; i++) {
for (int j=i-1; j>=1; j--) {
if (arr[i].x-arr[j].x<lSet) {
continue;
}
if (arr[i].x-arr[j].x>rSet) {
break;
}
f[i]=max(f[i],f[j]+arr[i].s);
if (f[i]>=k) {
return true;
}
}
}
return false;
}

BIN
Luogu/P3957/build/Debug/outDebug Executable file

Binary file not shown.