1 5 Add lcy 1 Add lyd 19 Find 11 Find 13 Add zxs 10
Case #1: 1 2 lyd 2
使用STL的map,map带有lower_bound()注意用法就好了。水水水
/*****************************************************************> File Name: tmp.cpp> Author: Uncle_Sugar> Mail: uncle_sugar@qq> Created Time: 2016年02月19日 星期五 15时07分29秒****************************************************************/
# include <cstdio>
# include <cstring>
# include <cmath>
# include <cstdlib>
# include <iostream>
# include <iomanip>
# include <set>
# include <map>
# include <vector>
# include <stack>
# include <queue>
using namespace std;const int debug = 1;
const int size = 5000 + 10;
typedef long long ll;int PersonNo = 0;
struct person{char name[20];person(){}bool operator < (const person& cmper)const{return 0;}
};
typedef pair<int,int> pir;
map<pir,person> mp;void Add(){static person Tmp;int can;cin >> Tmp.name >> can;mp[pir(can,++PersonNo)] = Tmp;cout << mp.size() << 'n';
}
void Find(){int can;cin >> can;map<pir,person>::iterator it = mp.lower_bound(pir(can,-1));if (it=d())cout << n";else{cout << it->second.name << 'n';mp.erase(it);}}
int main()
{std::ios::sync_with_stdio(false);cin.tie(0);int i,j,k;int T;cin >> T;int ncase = 0;while (T--){cout << "Case #" << (++ncase) << ":n";mp.clear();PersonNo = 0;int n;cin >> n;char cmd[10];while (n--){cin >> cmd;switch (cmd[0]){case 'A':Add();break;case 'F':Find();break;}}}return 0;
}
本文发布于:2024-01-30 15:36:29,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170660019421035.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |