#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <vector>#include <set>#include <map>#include <cmath>#include <sstream>#include <iomanip>#include <queue>#include <ctime>using namespace std;template <class T> void checkmin(T &t,T x){if (x < t) t = x;}template <class T> void checkmax(T &t,T x){if (x > t) t = x;}template <class T> void _checkmin(T &t, T x){if (t == -1) t = x; if (x < t) t = x;}template <class T> void _checkmax(T &t, T x){if (t == -1) t = x; if (x > t) t = x;}typedef pair <int,int> PII;typedef pair <double,double> PDD;typedef long long lld;#define foreach(it,v) for (__typeof((v).begin()) it = (v).begin();it != (v).end();it++)#define DEBUG(a) cout << #a" = " << (a) << endl;#define DEBUGARR(a, n) for (int i = 0; i < (n); i++) { cout << #a"[" << i << "] = " << (a)[i] << endl; }const int N = 100005;const int M = 600005;const char Mon[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};const int ms[12] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};int n;double w[N];PII a[N];char buf[200];double f[M];vector <int> E[M];int getMonth() {scanf("%s", buf);for (int i = 0; i < 12; i++) {if (!strcmp(buf, Mon[i])) {return i;}}}int getDay() {int x;scanf("%d%s", &x, buf);return x;}int getTime() {int month = getMonth();int day = getDay();int hour, minute;scanf("%d:%d %s", &hour, &minute, buf);if (buf[0] == 'p') {hour += 12;}return (ms[month] + day) * 24 * 60 + hour * 60 + minute + 1;}int main(){while (scanf("%d", &n) != EOF) {for (int i = 0; i < M; i++) E[i].clear();for (int i = 0; i < n; i++) {a[i].first = getTime();a[i].second = getTime();a[i].second += 5;E[a[i].second].push_back(i);scanf("%lf", &w[i]);}memset(f, 0, sizeof(f));for (int i = 1; i < M; i++) {f[i] = f[i - 1];foreach (it, E[i]) {checkmax(f[i], f[a[*it].first] + w[*it]);}}printf("%.1lfn", f[M - 1]);}}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)