记录编号 | 65084 | 评测结果 | AAAAAA | ||
---|---|---|---|---|---|
题目名称 | [暑假培训2012] 黑叔 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 0.030 s | ||
提交时间 | 2013-07-25 15:43:58 | 内存使用 | 0.43 MiB | ||
#include <fstream> #include <string> #include <algorithm> using namespace std; int n; ifstream fin("hey.in"); ofstream fout("hey.out"); long long d=0; class node1 { public: int a,b; string c; }x[10002]; bool comp(node1 y,node1 z) { if(y.a<z.a) return 1; if(y.a==z.a&&y.c<z.c) return 1; return 0; } int main() { fin>>n; for(int i=1;i<=n;i++) { fin>>x[i].a>>x[i].c>>x[i].b; } sort(x+1,1+x+n,comp); d=x[1].a; for(int i=1;i<=n;i++) { if(x[i].a<d) { fout<<x[i].c<<" went out at time "<<d<<endl; d+=x[i].b; } else { fout<<x[i].c<<" went out at time "<<x[i].a<<endl; d=x[i].a+x[i].b; } } fin.close(); fout.close(); return 0; }