摘要: 一眼二分。 二分左边界应该取$0$而不能取$a$数组中最小值(起码是最小值减$1$,因为要求严格大于$E$的天数),右边界由题目得为$N$。 const int N=1e5+10; int a[N]; int n; bool check(int x) { int cnt=0; for(int i=0 阅读全文
posted @ 2021-02-17 23:19 Dazzling! 阅读(53) 评论(0) 推荐(0) 编辑
摘要: 这不双指针板子题吗🎈。 const int N=1e5+10; int a[N]; int n,m; int main() { cin>>n>>m; for(int i=0;i<n;i++) cin>>a[i]; sort(a,a+n); int l=0,r=n-1; bool ok=false; 阅读全文
posted @ 2021-02-17 21:14 Dazzling! 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 对输入的每一个数,进行3n+1猜想的操作,对其中经过的每一个数x,插入集合中表示x被覆盖。 记录关键数,并从大到小排序,最后输出即可。 const int N=110; int a[N]; set<int> S; int n; int main() { cin>>n; for(int i=0;i<n 阅读全文
posted @ 2021-02-17 21:02 Dazzling! 阅读(23) 评论(0) 推荐(0) 编辑
摘要: 水~。 map<int,int> mp; int n; int main() { cin>>n; for(int i=0;i<n;i++) { int team_id,player_id,grade; scanf("%d-%d %d",&team_id,&player_id,&grade); mp[ 阅读全文
posted @ 2021-02-17 19:50 Dazzling! 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 既然要按PATest的顺序输出,那么就开一个数组cnt[6], 用来记录六个字符分别出现的个数(同时用一个变量tot记录总个数)。这样在读入字符串之后,就可以直接统计出这个数组。 遍历cnt数组,如果cnt[j]不为0,那么输出dict[i],并让cnt[i]减1、sum减1。如果sum变为0,那么 阅读全文
posted @ 2021-02-17 19:43 Dazzling! 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 水~。 map<char,int> mp; int main() { string s; getline(cin,s); for(auto t:s) if(isalpha(t)) mp[tolower(t)]++; char c='a'; for(auto t:mp) if(t.se > mp[c] 阅读全文
posted @ 2021-02-17 19:24 Dazzling! 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 水题~。 注意:商店每串珠子都不拆开售卖,只能整串购买。 map<char,int> mpa,mpb; string a,b; int main() { cin>>a>>b; for(auto t:a) mpa[t]++; for(auto t:b) mpb[t]++; int buy=0,miss 阅读全文
posted @ 2021-02-17 18:58 Dazzling! 阅读(46) 评论(0) 推荐(0) 编辑
摘要: 水题。 int cnt[105]; int n,m; int main() { cin>>n; for(int i=0;i<n;i++) { int x; cin>>x; cnt[x]++; } cin>>m; for(int i=0;i<m;i++) { int x; cin>>x; if(i) 阅读全文
posted @ 2021-02-17 18:26 Dazzling! 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 兄弟题1084 Broken Keyboard (20 分),一样的水~。 ps:`当按键都没坏的时候,输入可能为空,要用getline而不能用cin。 bool vis[200]; string a,b; int main() { getline(cin,a); getline(cin,b); f 阅读全文
posted @ 2021-02-17 17:13 Dazzling! 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 水题~。 set<char> S; set<char> res; string a,b; int main() { cin>>a>>b; for(auto t:b) { t=toupper(t); S.insert(t); } for(auto t:a) { t=toupper(t); if(S.c 阅读全文
posted @ 2021-02-17 16:59 Dazzling! 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 屑题。 题意 给出两个数,将它们写成保留N位小数的科学计数法后是否相等。如果相等,则输出YES,并给出该转换结果;如果不相等,则输出NO,并分别给出两个数的转换结果。 题目的要求是将两个数改写为科学计数法的形式,然后判断它们是否相等。而科学计数法的写法一定是如下格式:$0.a_1a_2a_3 \cd 阅读全文
posted @ 2021-02-17 16:40 Dazzling! 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 原代码,在$\color$上能取得$25pts$的满分好成绩,但在其他地方都超时了,gg。 set<int> S[55]; double res[55][55]; int n,m; void init() { for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) 阅读全文
posted @ 2021-02-17 12:07 Dazzling! 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 兄弟题1039 Course List for Student (25 分),一样很水。 vector<string> course[2510]; int n,m; int main() { cin>>n>>m; for(int i=0;i<n;i++) { string name; name.re 阅读全文
posted @ 2021-02-17 11:20 Dazzling! 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 水题,用c++读入最后一个点会超时。 const int N=40010; map<string,vector<int>> mp; int n,m; int main() { cin>>n>>m; while(m--) { int course,k; scanf("%d%d",&course,&k) 阅读全文
posted @ 2021-02-17 11:12 Dazzling! 阅读(8) 评论(0) 推荐(0) 编辑
摘要: C++为使用者提供了标准模板库( Standard Template Library,STL),其中封装了很多相当实用的容器(读者可以先把容器理解成能够实现很多功能的东西),不需要费力去实现它们的细节而直接调用函数来实现很多功能,十分方便。 vector vector翻译为向量,但是这里使用“变长数 阅读全文
posted @ 2021-02-17 10:53 Dazzling! 阅读(17) 评论(0) 推荐(0) 编辑
摘要: 带模拟。 题意 给出N条记录,每条记录给出一辆车的车牌号、当前时刻以及出入校情况(入校(in)还是出校(out))。然后给出K个查询,每个查询给出一个时刻,输出在这个时刻校园内的车辆数。 查询完毕后输出在学校内停留时间最长的车辆的车牌号(如果有多个,就一并输出)和对应的停留时间。 注意: 每个 in 阅读全文
posted @ 2021-02-17 10:05 Dazzling! 阅读(31) 评论(0) 推荐(0) 编辑