比赛 |
防止颓废的小练习v0.2 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
题目名称 |
观光公交 |
最终得分 |
100 |
用户昵称 |
KZNS |
运行时间 |
0.219 s |
代码语言 |
C++ |
内存使用 |
0.31 MiB |
提交时间 |
2016-10-18 10:05:00 |
显示代码纯文本
//KZNS
#include <cstdio>
using namespace std;
#define Nmax 1003
int N, M, K;
int dis[Nmax];
int ans = 0;
int gtm[Nmax] = {0};
int upn[Nmax] = {0};
int don[Nmax] = {0};
void rin() {
scanf("%d %d %d", &N, &M, &K);
for (int i = 1; i < N; i++)
scanf("%d", dis + i);
int a, b, c;
for (int i = 0; i < M; i++) {
scanf("%d %d %d", &a, &b, &c);
if (a > gtm[b]) {
ans += upn[b] * (a - gtm[b]);
gtm[b] = a;
}
else {
ans += gtm[b] - a;
}
upn[b]++;
don[c]++;
}
gtm[N] = 0x7fffffff;
}
void work() {
int ti = 0;
int ts = 0;
int cn = 0;
int ttm = 0;
bool fff = false;
int ii = 0, ss = 0;
for (int i = 1; i <= N; i++) {
if (fff) {
ts += don[i];
if (ttm < gtm[i]) {
if (ts > ss) {
ss = ts;
ii = ti;
}
ttm = gtm[i];
fff = false;
}
}
if (!fff && dis[i]) {
fff = true;
ti = i;
ts = 0;
ttm -= 1;
}
ttm += dis[i];
}
dis[ii]--;
}
void count() {
int cn = 0;
int ttm = 0;
for (int i = 1; i < N; i++) {
cn = cn - don[i];
if (ttm > gtm[i])
ans += upn[i] * (ttm - gtm[i]);
else {
ans += cn * (gtm[i] - ttm);
ttm = gtm[i];
}
cn += upn[i];
ans += cn * dis[i];
ttm += dis[i];
}
}
int main() {
freopen("bus.in", "r", stdin);
freopen("bus.out", "w", stdout);
rin();
for (int i = 0; i < K; i++)
work();
count();
printf("%d\n", ans);
return 0;
}
//UBWH