From 6c2387b780134c079dff5433c1809fde5bbc374b Mon Sep 17 00:00:00 2001 From: TooYoungTooSimp <6648049+TooYoungTooSimp@users.noreply.github.com> Date: Mon, 19 Dec 2016 17:24:51 +0800 Subject: [PATCH] =?UTF-8?q?bzoj=201816=202429=202563=203098=20=EF=BC=88?= =?UTF-8?q?=E6=8A=84=E9=A2=98=E8=A7=A3=E7=9C=9F=E7=9A=84=E5=A5=BD=E7=88=BD?= =?UTF-8?q?=E5=95=8A=E4=BD=86=E6=98=AF=E6=84=9F=E8=A7=89=E5=A5=BD=E5=A0=95?= =?UTF-8?q?=E8=90=BD=E5=95=8A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OnlineJudges/lydsy/1816.cpp | 22 +++++++++++++++++++++ OnlineJudges/lydsy/2429.cpp | 38 +++++++++++++++++++++++++++++++++++++ OnlineJudges/lydsy/2563.cpp | 24 +++++++++++++++++++++++ OnlineJudges/lydsy/3098.cpp | 8 ++++++++ 4 files changed, 92 insertions(+) create mode 100644 OnlineJudges/lydsy/1816.cpp create mode 100644 OnlineJudges/lydsy/2429.cpp create mode 100644 OnlineJudges/lydsy/2563.cpp create mode 100644 OnlineJudges/lydsy/3098.cpp diff --git a/OnlineJudges/lydsy/1816.cpp b/OnlineJudges/lydsy/1816.cpp new file mode 100644 index 0000000..a995d25 --- /dev/null +++ b/OnlineJudges/lydsy/1816.cpp @@ -0,0 +1,22 @@ +//抄的题解,谁告诉我这个check到底是什么意思 +#include +int n, m, a[51]; +bool check(int x) +{ + int cnt = m < x ? m : x; + for (int i = 0; i < n; i++) if (a[i] < x) + { + cnt -= x - a[i]; + if (cnt < 0) return false; + } + return true; +} +int main() +{ + scanf("%d%d", &n, &m); + for (int i = 0; i < n; i++) scanf("%d", a + i); + int l = 0, r = 0x3f3f3f3f, mid; + while (l < r) check(mid = (l + r) >> 1) ? l = mid + 1 : r = mid; + printf("%d", l - 1); + return 0; +} \ No newline at end of file diff --git a/OnlineJudges/lydsy/2429.cpp b/OnlineJudges/lydsy/2429.cpp new file mode 100644 index 0000000..68d6454 --- /dev/null +++ b/OnlineJudges/lydsy/2429.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include +using namespace std; +int fa[1010], X[1010], Y[1010], monkeys[510], m, n, ecnt, ans1; +double ans2; +int Find(int x) { return fa[x] == -1 ? x : fa[x] = Find(fa[x]); } +struct edge +{ + int u, v; + double l; + bool operator<(const edge &rhs) const { return l < rhs.l; } +} edges[1000010]; +int main() +{ + memset(fa, -1, sizeof(fa)); + scanf("%d", &m); + for (int i = 0; i < m; i++) scanf("%d", monkeys + i); + sort(monkeys, monkeys + m); + scanf("%d", &n); + for (int i = 1; i <= n; i++) + scanf("%d%d", X + i, Y + i); + for (int i = 1; i <= n; i++) + for (int j = 1; j < i; j++, ecnt++) + edges[ecnt].u = i, edges[ecnt].v = j, edges[ecnt].l = + sqrt((X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j])); + sort(edges, edges + ecnt); + for (int i = 0, fx, fy; i < ecnt; i++) + if ((fx = Find(edges[i].u)) != (fy = Find(edges[i].v))) + { + fa[fx] = fy; + ans1++, ans2 = edges[i].l; + if (ans1 == n - 1) break; + } + printf("%d", int(monkeys + m - lower_bound(monkeys, monkeys + m, ans2))); + return 0; +} \ No newline at end of file diff --git a/OnlineJudges/lydsy/2563.cpp b/OnlineJudges/lydsy/2563.cpp new file mode 100644 index 0000000..7763edd --- /dev/null +++ b/OnlineJudges/lydsy/2563.cpp @@ -0,0 +1,24 @@ +#include +#include +int a[10010]; +int main() +{ + int n, m, ans = 0; + scanf("%d%d", &n, &m); + for (int i = 1, x; i <= n; i++) + { + scanf("%d", &x); + ans -= x; + a[i] = x << 1; + } + for (int i = 1, x, y, z; i <= m; i++) + { + scanf("%d%d%d", &x, &y, &z); + ans -= z, a[x] += z, a[y] += z; + } + std::sort(a + 1, a + n + 1); + for (int i = 2; i <= n; i += 2) + ans += a[i]; + printf("%d", ans); + return 0; +} \ No newline at end of file diff --git a/OnlineJudges/lydsy/3098.cpp b/OnlineJudges/lydsy/3098.cpp new file mode 100644 index 0000000..6525345 --- /dev/null +++ b/OnlineJudges/lydsy/3098.cpp @@ -0,0 +1,8 @@ +#include +#include +int main() +{ + printf("100000 %d\n", ((rand() << 16) | rand()) % 100000 + 1); + for (int i = 0; i < 100000; i++) putchar(rand() % 26 + 'a'); + return 0; +} \ No newline at end of file