diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd8b854 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.* +build +!.gitignore \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..633a4b6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.10) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +project(alogrithm_2024) + +add_executable(P1031 ${CMAKE_CURRENT_LIST_DIR}/P1031/main.cpp) \ No newline at end of file diff --git a/P1031/main.cpp b/P1031/main.cpp new file mode 100644 index 0000000..6f3d533 --- /dev/null +++ b/P1031/main.cpp @@ -0,0 +1,32 @@ +#include +#include + +int n; +int a[(int)1e4+5]; + +int main(){ + std::ios::sync_with_stdio(false),std::cin.tie(nullptr),std::cout.tie(nullptr); + + std::cin>>n; + + int sum=0; + for(int i=1;i<=n;i++){ + std::cin>>a[i]; + sum+=a[i]; + } + + int avg = sum/n; + + int ans = 0; + for(int i=1;iavg){ + a[i+1]+=a[i]-avg; + }else if(a[i]