📄 1559.cpp
字号:
/* This Code is Submitted by wywcgs for Problem 1559 on 2006-01-12 at 15:19:55 */
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAX = 1024;
const int L_MAX = 32;
class Photo {
public:
char lic[L_MAX], intro[8];
int d, h, s, l;
int make();
bool operator <(const Photo&) const;
};
int Photo::make() {
char line[128];
if(gets(line) == NULL) return 0;
else if(line[0] == 0) return -1;
sscanf(line, "%s %*d:%d:%d:%d %s %d", lic, &d, &h, &s, intro, &l);
return 1;
}
bool Photo::operator <(const Photo& p) const {
int r = strcmp(lic, p.lic);
if(r != 0) return r < 0;
else if(d != p.d) return d < p.d;
else if(h != p.h) return h < p.h;
else if(s != p.s) return s < p.s;
else return strcmp(intro, p.intro) < 0;
}
int main()
{
Photo photo[MAX];
int n, cost[L_MAX];
int t, r, i;
bool end = false;
for(t = 0; !end; t++) {
if(t != 0) putchar('\n');
for(i = 0; i < 24; i++)
if(scanf("%d\n", &cost[i]) == EOF) return 0;
for(n = 0; (r = photo[n].make()) != -1; n++)
if(r == 0) { end = true; break; }
sort(photo, photo+n);
int bill = 200, en;
bool enter = false;
for(i = 0; i < n; i++) {
if(!strcmp(photo[i].intro, "enter")) enter = true, en = i;
else if(enter) {
bill += cost[photo[en].h]*abs(photo[en].l-photo[i].l) + 100;
enter = false;
}
if(i == n-1 || strcmp(photo[i].lic, photo[i+1].lic)) {
if(bill != 200) printf("%s $%d.%02d\n", photo[i].lic, bill/100, bill%100);
bill = 200; enter = false;
}
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -