当前位置:网站首页>Codeforces Round #799 (Div. 4)(8/8)
Codeforces Round #799 (Div. 4)(8/8)
2022-07-22 08:58:00 【eyuhaobanga】
AC代码:
#include <bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; for (int i = 0; i < t; i++){ int a, b, c, d; cin >> a >> b >> c >> d; int ans = 0; if (b > a){ ans++; } if (c > a){ ans++; } if (d > a){ ans++; } cout << ans << endl; } }
AC代码:
#include <bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; for (int i = 0; i < t; i++){ int n; cin >> n; vector<int> a(n); for (int j = 0; j < n; j++){ cin >> a[j]; } sort(a.begin(), a.end()); int cnt = unique(a.begin(), a.end()) - a.begin(); if (cnt % 2 != n % 2){ cnt--; } cout << cnt << endl; } }
AC代码:
#include <bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; for (int i = 0; i < t; i++){ vector<string> S(8); for (int j = 0; j < 8; j++){ cin >> S[j]; } int r, c; for (int j = 1; j < 7; j++){ for (int k = 1; k < 7; k++){ int cnt = 0; for (int x = j - 1; x <= j + 1; x++){ for (int y = k - 1; y <= k + 1; y++){ if (S[x][y] == '#'){ cnt++; } } } if (cnt == 5){ r = j; c = k; } } } cout << r + 1 << ' ' << c + 1 << endl; } }
AC代码:
#include <bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; for (int i = 0; i < t; i++){ int h; char c; int m; int x; cin >> h >> c >> m >> x; int T = h * 60 + m; vector<bool> used(1440, false); used[T] = true; while (true){ T += x; T %= 1440; if (used[T]){ break; } used[T] = true; } int ans = 0; for (int j = 0; j < 1440; j++){ if (used[j]){ int hh = j / 60, mm = j % 60; if (mm / 10 == hh % 10 && mm % 10 == hh / 10){ ans++; } } } cout << ans << endl; } }
AC代码:
#include <bits/stdc++.h> using namespace std; int main(){ int t; cin >> t; for (int i = 0; i < t; i++){ int n, s; cin >> n >> s; vector<int> a(n); for (int j = 0; j < n; j++){ cin >> a[j]; } vector<int> p; p.push_back(-1); for (int j = 0; j < n; j++){ if (a[j] == 1){ p.push_back(j); } } p.push_back(n); int cnt = p.size() - 2; if (cnt < s){ cout << -1 << endl; } else { int cnt = p.size(); int ans = n; for (int j = 0; j < cnt - s - 1; j++){ ans = min(ans, n - (p[j + s + 1] - p[j]) + 1); } cout << ans << endl; } } }
AC代码:
#include <bits/stdc++.h> using namespace std; using LL = long long; void Solve() { int n; cin >> n; vector<int> a(n); vector<int> cnt(10); for (int i = 0; i < n; i++) { cin >> a[i]; cnt[a[i] % 10]++; } for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { for (int k = 0; k < 10; k++) { if (cnt[i] && cnt[j] && cnt[k]) { cnt[i]--; cnt[j]--; cnt[k]--; if (cnt[i] < 0 || cnt[j] < 0 || cnt[k] < 0) { cnt[i]++; cnt[j]++; cnt[k]++; continue; } int x = i + j + k; if (x % 10 == 3) { cout << "YES\n"; return; } cnt[i]++; cnt[j]++; cnt[k]++; } } } } cout << "NO\n"; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { Solve(); } return 0; }
AC代码:
#include <bits/stdc++.h> using namespace std; using LL = long long; void Solve() { int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int ans = 0; for (int i = 1; i < n;) { int cnt = 1; while (i < n && a[i - 1] < 2 * a[i]) { cnt++; i++; } if (cnt >= k + 1) { ans += cnt - k; cnt = 1; i++; } else { cnt = 1; i++; } } cout << ans << '\n'; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { Solve(); } return 0; }
AC代码:
#include <bits/stdc++.h> using namespace std; using LL = long long; void Solve() { int n; cin >> n; vector<int> a(n); map<int, vector<int>> mp; for (int i = 0; i < n; i++) { cin >> a[i]; mp[a[i]].push_back(i); } map<int, vector<int>>::iterator it; int ans = 0, l = -1, r = -1, maxx = 0; for (it = mp.begin(); it != mp.end(); it++) { int len = it->second.size(); int tmp = -0x3f3f3f3f, pos; for (int i = 0; i < len; i++) { if (it->second[i] - 2 * i > tmp) { tmp = it->second[i] - 2 * i; pos = it->second[i]; } int cnt = 2 * i - it->second[i] + tmp + 1; if (cnt > maxx) { maxx = cnt; ans = it->first; l = pos; r = it->second[i]; } } } cout << ans << " " << l + 1 << " " << r + 1 << '\n'; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { Solve(); } return 0; }
边栏推荐
- 2021-10-18 burn bare board program with EOP
- QT筆記—— QTableWidget 之 拖拽行數 和 移動
- QT notes - vs generating multiple exe files for a project
- 「武汉理工大学 软件工程复习」第五章 | 软件体系结构
- Gbase8s database set autofree statement
- 小程序CMS动态处理数据之内容模型和内容集合的使用
- Copy of file descriptor
- QT notes - qudpsocket of network communication
- 二、注解
- 力扣解法汇总241-为运算表达式设计优先级
猜你喜欢
Qt|编辑框的使用总结
fcntl函数
"Review of software engineering in Wuhan University of technology" Chapter 2 | software process model
【Rust】为什么我建议你学一下 Rust | Rust 初探
What level do programmers need to reach to get 20K monthly salary without pressure?
"Review of software engineering in Wuhan University of technology" Chapter 7 | software testing
MySQL修改密码不成功(无效)的解决办法
Qt Notes - nombre de lignes traînées et de mouvements pour le Widget qtablewidget
需要达到什么水平,程序员才能顺利拿到20k月薪无压力?
QT笔记——操作Execl
随机推荐
【How To 系列】好友裂变平台搭建
力扣解法汇总731-我的日程安排表 II
融合注意力机制和BSRU的工业互联网安全态势预测方法
3.Transbot修改显示分辨率
Fabric.js 居中元素
A trick to teach you how to visualize recruitment data ~ is there anyone who can't analyze these data cases?
QT笔记——QTableWidget 之 指定某列排序
Gbase8s database set autofree statement
关于STemwin中,外部实体按键操作Spinbox控件(fishing_2)
About the external entity key operation spinbox control in stemwin (fishing_2)
如何消除 MySQL表中的字段特别设置的字符集和排序规则?
C#入门系列(二十七) -- LINQ简析
Reentrant function
Understanding of continue in C language (fishing_1)
Lesson 12 MySQL high availability component MHA
What level do programmers need to reach to get 20K monthly salary without pressure?
在ubuntu中使用pypyodbc无法连接sql server
Multi type low rate DDoS attack detection method based on hybrid deep learning
互斥锁和信号量
第十二讲 MySQL之高可用组件MHA