From b7e8f89065b76939aa6e209ea898013c77392035 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Wed, 7 Jul 2021 11:46:37 +0800 Subject: [PATCH] =?UTF-8?q?P1167=20=E5=88=B7=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R52536339 --- Luogu/problem/P1167/P1167.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Luogu/problem/P1167/P1167.cpp diff --git a/Luogu/problem/P1167/P1167.cpp b/Luogu/problem/P1167/P1167.cpp new file mode 100644 index 00000000..d1005d1d --- /dev/null +++ b/Luogu/problem/P1167/P1167.cpp @@ -0,0 +1,32 @@ +#include + +using namespace std; + +time_t getTime() { + tm t; + scanf("%d-%d-%d-%d:%d", &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min); + t.tm_year -= 1900; + t.tm_mon -= 1; + t.tm_isdst = t.tm_sec = 0; + return mktime(&t); +} + +int main() { + time_t time_start, time_end, time_left; + int n, a[5005], ans = 0; + cin >> n; + for (int i = 0; i < n; i++) { + cin >> a[i]; + } + time_start = getTime(); + time_end = getTime(); + time_left = (time_end - time_start) / 60; + sort(a, a + n); + for (int i = 0; i < n; i++) { + time_left -= a[i]; + if (time_left < 0) break; + ans++; + } + cout << ans << endl; + return 0; +}