hdu1103 模拟题……
7176383 | 2012-11-17 11:06:13 | Accepted | 1103 | 15MS | 292K | 1454 B | C++ | TO_Asia |
7176283 | 2012-11-17 10:57:31 | Wrong Answer | 1103 | 15MS | 288K | 1176 B | C++ | TO_Asia |
7176200 | 2012-11-17 10:47:35 | Wrong Answer | 1103 | 0MS | 288K | 1175 B | C++ | TO_Asia |
一开始悲催的 想用STL 事实证明强大的算法秒杀一切STL。
View Code
#include<iostream> #include<string> #include<string.h> #include<deque> #include<algorithm> using namespace std; int n[3]; /*struct node { int times,num; }; deque<node> q[3];*/ int main() { string s; node temp; int diner,ans,now; int map[3][111]; while(scanf("%d%d%d",&n[0],&n[1],&n[2]),(n[0]!=0&&n[1]!=0&&n[2]!=0)) { memset(map,0,sizeof(map)); ans=0; /*temp.times=temp.num=0; q[0].push_back(temp);q[1].push_back(temp);q[2].push_back(temp);*/ while(cin>>s) { if(s=="#")break; scanf("%d",&diner); if(diner==1||diner==2)now=0; else if(diner==3||diner==4)now=1; else if(diner==5||diner==6)now=2; int time=((s[0]-'0')*10+s[1]-'0')*60+(s[3]-'0')*10+s[4]-'0'; /*temp.num=diner;temp.times=time;*/ sort(map[now],map[now]+n[now]); if(map[now][0]<=time) { ans+=diner; if(map[now][0]+30<=time)map[now][0]=time; else map[now][0]+=30; } /*while(!q[now].empty()&&time-q[now].front().times>=30) {ans+=q[now].front().num;q[now].pop_front();} if(q[now].empty())q[now].push_back(temp); else { if(q[now].size()<n[now])q[now].push_back(temp); else if(q[now].size()-n[now]>=n[now])continue; else if(time-q[now][q[now].size()-n[now]].times<=30) q[now].push_back(temp); }*/ } /*for(int i=0;i<3;i++) while(!q[i].empty()) {ans+=q[i].front().num;q[i].pop_front();}*/ cout<<ans<<endl; } return 0; }
水了个水