Description
Oaiei is busy working with his graduation design recently. If he can not complete it before the end of the month, and he can not graduate! He will be very sad with that, and he needs your help. There are 24 hours a day, oaiei has different efficiency in different time periods, such as from 0 o’clock to 8 o'clock his working efficiency is one unit per hour, 8 o'clock to 12 o'clock his working efficiency is ten units per hour, from 12 o'clock to 20 o'clock his working efficiency is eight units per hour, from 20 o'clock to 24 o'clock his working efficiency is 5 units per hour. Given you oaiei’s working efficiency in M periods of time and the total time N he has, can you help him calculate his greatest working efficiency in time N.
Input
There are multiple tests. In each test the first line has two integer N (2 <= N <= 50000) and M (1 <= M <= 500000), N is the length of oaiei’s working hours; M is the number of periods of time. The following M lines, each line has three integer S, T, P (S < T, 0 < P <= 200), represent in the period of time from S to T oaiei’s working efficiency is P units per hour. If we do not give oaiei’s working efficiency in some periods of time, his working efficiency is zero. Oaiei can choose part of the most effective periods of time to replace the less effective periods of time. For example, from 5 o’clock to 10 o’clock his working efficiency is three units per hour and from 1 o’clock to 7 o’clock his working efficiency is five units per hour, he can choose working with five units per hour from 1 o’clocks to 7 o’clock and working with three units per hour from 7 o’clock to 10 o’clock.
Output
You should output an integer A, which is oaiei’s greatest working efficiency in the period of time from 0 to N.
Sample Input
Sample Output
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 50000 + 5;
struct tree {
int max_val;
int lh, rh;
void exp_max(int val) {
max_val = max(max_val, val);
}
} T[maxn<<2];
void Build(int root, int l, int r)
{
T[root].max_val = 0;
T[root].lh = l;
T[root].rh = r;
if(l + 1 >= r) return;
int mid = (l + r) >> 1;
Build(root<<1, l, mid);
Build(root<<1|1, mid, r);
}
void Insert(int root, int l, int r, int val)
{
if(T[root].rh <= l || T[root].lh >= r) return;
if(T[root].lh >= l && T[root].rh <= r) {
T[root].exp_max(val);
return;
}
Insert(root<<1, l, r, val);
Insert(root<<1|1, l, r, val);
}
int Query(int root, int l, int r)
{
if(l + 1 >= r) return T[root].max_val;
T[root<<1].exp_max(T[root].max_val);
T[root<<1|1].exp_max(T[root].max_val);
int mid = (l + r) >> 1;
return Query(root<<1, l, mid) + Query(root<<1|1, mid, r);
}
int main()
{
// freopen("in", "r", stdin);
int n, m;
while(~scanf("%d%d", &n, &m)) {
memset(T, 0, sizeof(T));
Build(1, 0, n);
int s, t, p;
for(int i = 0; i < m; ++i) {
scanf("%d%d%d", &s, &t, &p);
Insert(1, s, t, p);
}
printf("%d\n", Query(1, 0, n));
}
return 0;
}
本文深入探讨了如何通过优化时间分配和利用不同的工作效率矩阵,实现个人或团队的工作效率最大化。通过案例分析,展示了如何灵活调整工作强度以适应不同时间段的效率变化,从而在有限的时间内完成更多任务。特别强调了通过合理安排工作时段,选择最适合自身的工作状态和任务特性的时间段进行高效工作,以及如何通过调整工作强度来应对任务难度和截止日期的挑战。
417

被折叠的 条评论
为什么被折叠?



