diff --git a/.vs/Altu-Bitu/FileContentIndex/ad54c587-404f-4f51-b346-8a400b153708.vsidx b/.vs/Altu-Bitu/FileContentIndex/ad54c587-404f-4f51-b346-8a400b153708.vsidx new file mode 100644 index 0000000..5a09f78 Binary files /dev/null and b/.vs/Altu-Bitu/FileContentIndex/ad54c587-404f-4f51-b346-8a400b153708.vsidx differ diff --git a/.vs/Altu-Bitu/FileContentIndex/f2d999a4-b74f-4cdf-9d6e-282e2abdfec6.vsidx b/.vs/Altu-Bitu/FileContentIndex/f2d999a4-b74f-4cdf-9d6e-282e2abdfec6.vsidx deleted file mode 100644 index e43ae94..0000000 Binary files a/.vs/Altu-Bitu/FileContentIndex/f2d999a4-b74f-4cdf-9d6e-282e2abdfec6.vsidx and /dev/null differ diff --git a/.vs/Altu-Bitu/v17/.wsuo b/.vs/Altu-Bitu/v17/.wsuo index 3c1fd1a..ee3845c 100644 Binary files a/.vs/Altu-Bitu/v17/.wsuo and b/.vs/Altu-Bitu/v17/.wsuo differ diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index 62352e1..db94a45 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -1,8 +1,8 @@ { "ExpandedNodes": [ "", - "\\05_우선순위큐" + "\\06_그리디" ], - "SelectedNode": "\\05_우선순위큐\\2075.cpp", + "SelectedNode": "\\06_그리디\\17451.cpp", "PreviewInSolutionExplorer": false } \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 285e5bf..e42995f 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git "a/06_\352\267\270\353\246\254\353\224\224/1213.cpp" "b/06_\352\267\270\353\246\254\353\224\224/1213.cpp" new file mode 100644 index 0000000..4111275 --- /dev/null +++ "b/06_\352\267\270\353\246\254\353\224\224/1213.cpp" @@ -0,0 +1,9 @@ +#include + +using namespace std; + +int main(){ + + +return 0; +} \ No newline at end of file diff --git "a/06_\352\267\270\353\246\254\353\224\224/17451.cpp" "b/06_\352\267\270\353\246\254\353\224\224/17451.cpp" new file mode 100644 index 0000000..1036fd8 --- /dev/null +++ "b/06_\352\267\270\353\246\254\353\224\224/17451.cpp" @@ -0,0 +1,31 @@ +#include +#include + +using namespace std; + +int main(){ + + int n; + vector v; //ӵ + v.push_back(0); + + //Է + cin >> n; + for(int i=1; i<=n; i++){ + int input; + cin >> input; + v.push_back(input); + } + + // ӵ ϸ鼭 ּ ӵ + for(int i=n-1; i>=1; i--){ + if(v[i] < v[i+1]){// ӵ ӵ + long long times = (v[i+1]-1) / v[i] + 1; // ӵ ÷ϴ + v[i] *= times; // ӵ + } + } + + cout << v[1]; + + return 0; +} \ No newline at end of file diff --git "a/06_\352\267\270\353\246\254\353\224\224/18111.cpp" "b/06_\352\267\270\353\246\254\353\224\224/18111.cpp" new file mode 100644 index 0000000..87d1450 --- /dev/null +++ "b/06_\352\267\270\353\246\254\353\224\224/18111.cpp" @@ -0,0 +1,61 @@ +#include +using namespace std; + +int N, M, B; +int minHeight = 1e9, maxHeight; +int minCost = 1e9, finalHeight; +int field[500][500]; + +void calculateCost(int targetHeight) { + int blocksIn = B; + int totalCost = 0; + + // + for (int i = 0; i < N; i++) { + for (int j = 0; j < M; j++) { + if (field[i][j] > targetHeight) { + totalCost += 2 * (field[i][j] - targetHeight); + blocksIn += field[i][j] - targetHeight; + } + } + } + + // ߰ + for (int i = 0; i < N; i++) { + for (int j = 0; j < M; j++) { + if (field[i][j] < targetHeight) { + totalCost += targetHeight - field[i][j]; + blocksIn -= targetHeight - field[i][j]; + if (blocksIn < 0) return; + } + } + } + + // + if (totalCost <= minCost) { + minCost = totalCost; + finalHeight = max(finalHeight, targetHeight); + } +} + +int main() { + ios_base::sync_with_stdio(0); + cin.tie(NULL); cout.tie(NULL); + + cin >> N >> M >> B; + for (int i = 0; i < N; i++) { + for (int j = 0; j < M; j++) { + cin >> field[i][j]; + minHeight = min(minHeight, field[i][j]); + maxHeight = max(maxHeight, field[i][j]); + } + } + + for (int i = minHeight; i <= maxHeight; i++) { + calculateCost(i); + } + + cout << minCost << " " << finalHeight; + + return 0; +}