A - Large Digits

按要求求出两个数的每位之和,进行比较即可。

时间复杂度 \(\mathcal{O}(\log(AB))\)。

B - Gentle Pairs

枚举所有点对求斜率。

时间复杂度 \(\mathcal{O}(N^2)\)。

int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int n;
cin >> n;
int x[1010], y[1010];
int cnt = 0;
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i];
}
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j) {
if (i != j)
if (abs(y[i] - y[j]) <= abs(x[i] - x[j])) cnt++;
}
cout << cnt / 2 << "\n";
return 0;
}

C - 1-SAT

用两个HashSet分别存储不带!和带!的字符串的纯字符部分,求两个HashSet的交集。若有交集,则输出其中任意一个字符串;否则按要求输出satisfiable

时间复杂度 \(\mathcal{O}(N)\)。

int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int n;
cin >> n;
string s;
unordered_set<string> s1, s2;
for (int i = 0; i < n; ++i) {
cin >> s;
if (s[0] == '!') s1.insert(s.substr(1));
else
s2.insert(s);
}
for (auto x : s1) {
if (s2.count(x)) {
cout << x << "\n";
return 0;
}
}
cout << "satisfiable\n";
return 0;
}

D - Choose Me

将所有城镇按照\(2A_i+B_i\)降序排列,然后贪心选取即可。

时间复杂度 \(\mathcal{O}(N\log N)\)。

using ll = long long;
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int n;
cin >> n;
vector<pair<ll, ll>> towns;
ll sa = 0, sb = 0; // T,A
for (int i = 0; i < n; ++i) {
int a, b;
cin >> a >> b;
towns.emplace_back(a, b);
sa += a;
}
sort(towns.begin(), towns.end(), [](pair<ll, ll>& p, pair<ll, ll>& q) {
return p.first * 2 + p.second > q.first * 2 + q.second;
});
for (int i = 0; i < n; ++i) {
if (sa < sb) {
cout << i << "\n";
return 0;
}
sa -= towns[i].first, sb += towns[i].first + towns[i].second;
}
cout << n << "\n";
return 0;
}

AtCoder Beginner Contest 187 题解的更多相关文章

  1. AtCoder Beginner Contest 154 题解

    人生第一场 AtCoder,纪念一下 话说年后的 AtCoder 比赛怎么这么少啊(大雾 AtCoder Beginner Contest 154 题解 A - Remaining Balls We ...

  2. AtCoder Beginner Contest 153 题解

    目录 AtCoder Beginner Contest 153 题解 A - Serval vs Monster 题意 做法 程序 B - Common Raccoon vs Monster 题意 做 ...

  3. AtCoder Beginner Contest 177 题解

    AtCoder Beginner Contest 177 题解 目录 AtCoder Beginner Contest 177 题解 A - Don't be late B - Substring C ...

  4. AtCoder Beginner Contest 184 题解

    AtCoder Beginner Contest 184 题解 目录 AtCoder Beginner Contest 184 题解 A - Determinant B - Quizzes C - S ...

  5. AtCoder Beginner Contest 173 题解

    AtCoder Beginner Contest 173 题解 目录 AtCoder Beginner Contest 173 题解 A - Payment B - Judge Status Summ ...

  6. AtCoder Beginner Contest 172 题解

    AtCoder Beginner Contest 172 题解 目录 AtCoder Beginner Contest 172 题解 A - Calc B - Minor Change C - Tsu ...

  7. AtCoder Beginner Contest 169 题解

    AtCoder Beginner Contest 169 题解 这场比赛比较简单,证明我没有咕咕咕的时候到了! A - Multiplication 1 没什么好说的,直接读入两个数输出乘积就好了. ...

  8. AtCoder Beginner Contest 148 题解

    目录 AtCoder Beginner Contest 148 题解 前言 A - Round One 题意 做法 程序 B - Strings with the Same Length 题意 做法 ...

  9. AtCoder Beginner Contest 151 题解报告

    总的来说,这次的题目比较水,然而菜菜的我并没有把所有题目都做完,话不多说,直接来干货: A:Next Alphabet 题目链接:https://atcoder.jp/contests/abc151/ ...

  10. AtCoder Beginner Contest 115 题解

    题目链接:https://abc115.contest.atcoder.jp/ A Christmas Eve Eve Eve 题目: Time limit : 2sec / Memory limit ...

随机推荐

  1. 基于 TCP 协议写的 FTP 管理小工具

    这是一个FTP(文件传输协议)管理工具,能够支持文件上传下载以及操作服务端的文件. 该工具由客户端和服务端组成.客户端与服务端通过Socket连接实现通信,客户端发送命令,服务端解析并执行相应的操作. ...

  2. 0x03.api接口

    API接口安全 HTTP类接口 SOAP----->http+xml REST------>传递资源 RPC类接口(非web):用于远程调用,类似于客户端和服务端.如,登录的时候,进入服务 ...

  3. MarkdownPad 文件访问权限受限导致软件打开后不久闪退解决方法

    近几天发现MarkdownPad有一些小问题,打开时会弹出以下报错信息,告诉你打开文件的权限不够 解决方法如下: 1.复制报错信息中的文件路径"Access to the path 'C:\ ...

  4. Linux笔记03: Linux常用命令_3.2目录操作命令

    3.2 目录操作命令 3.2.1 ls命令 ●命令名称:ls. ●英文原意:list directory contents. ●所在路径:/usr/bin/ls. ●执行权限:所有用户. ●功能描述: ...

  5. [CF1748D] ConstructOR

    题目描述 You are given three integers $ a $ , $ b $ , and $ d $ . Your task is to find any integer $ x $ ...

  6. “古剑山”第一届全国大学生网络攻防大赛-Crtpto | Misc WP

    Crypto babyRSA 题目信息 p=105570604806073931560404187362816308950408774915960751676958845800335871518600 ...

  7. Python 提取 Word 文档中的文本和图片

    将内容从 Word 文档中提取出来可以方便我们对其进行其他操作,如将内容储存在数据库中.将内容导入到其他程序中.用于 AI 训练以及制作其他文档等.第三方库 Spire.Doc for Python  ...

  8. 可视化学习:CSS transform与仿射变换

    引言 在几年前,我就在一些博客中看到关于CSS中transform的分析,讲到它与线性代数中矩阵的关系,但当时由于使用transform比较少,再加上我毕竟是个数学学渣,对数学有点畏难心理,就有点看不 ...

  9. 华企盾DSC导入离线客户端没有获取到信息

    安装客户端的时候禁用了网卡,导致导入离线客户端获取不到信息. 解决方法: 1.启用网卡,重启电脑 2.启用网卡,重装客户端

  10. Wifi BSSID获取

    代码很简单,通过wifiManager 获取wifiinfo,从而获取bssid, public static String getWifiSSID(Context context) { String ...