Codeforces Round #340 (Div. 2) C. Watering Flowers
来源:互联网 发布:巨人网络招聘2017 编辑:程序博客网 时间:2024/05/02 00:51
两种方法,一种n2,一种nlogn
#include <cstdio>#include <vector>typedef long long ll;using namespace std;ll pow(int a){ return a * (ll) a;}int main(){ int n, x1, x2, y1, y2; scanf("%d%d%d%d%d", &n, &x1, &y1, &x2, &y2); vector< pair<ll, ll> >vv(n); for (int i = 0; i < n; i++) { int a, b; scanf("%d%d", &a, &b); vv[i].first = pow(a - x1) + pow(b - y1); vv[i].second = pow(a - x2) + pow(b - y2); } vv.push_back({0, 0}); ll ans = 1e18; for (int i = 0; i <= n; i++) { ll r1 = vv[i].first; ll r2 = 0; for (int j = 0; j <= n; j++) { if (vv[j].first > r1) { r2 = max(r2, vv[j].second); } } ans = min(r1 + r2, ans); } printf("%I64d\n", ans); return 0;}
0 0
- Codeforces Round #340 (Div. 2) C. Watering Flowers
- Codeforces Round #340 (Div. 2) C. Watering Flowers
- Codeforces Round #340 (Div. 2)C. Watering Flowers
- Codeforces Round #340 (Div. 2)C. Watering Flowers(暴力)
- Codeforces Round #340 (Div. 2)C. Watering Flowers
- Codeforces Round #340 (Div. 2)-C. Watering Flowers
- Codeforces 617C Watering Flowers (Round #340 (Div. 2) C题) nlogn算法
- Codeforces Round #340 (Div. 2) 617C Watering Flowers(计算几何)
- Codeforces Round #340 (Div. 2) C. Watering Flowers(暴力枚举)
- Codeforces Round #340 (Div. 2) C. Watering Flowers 计算几何、圆和点
- Codeforces Round #340 -C - Watering Flowers-暴力+set
- 【Codeforces Round 340 (Div 2)C】【暴力排序枚举】Watering Flowers 2个灌溉器灌溉所有点最小的rr+RR
- Codeforces 617 C. Watering Flowers
- Codeforces 617C:Watering Flowers
- Codeforces 617C(Watering Flowers)
- CodeForces 617C Watering Flowers
- Codeforces Round #341 (Div. 2) C. Wet Shark and Flowers
- Codeforces Round #341 (Div. 2)--C. Wet Shark and Flowers
- ToolBar
- hadoop 2.6.3 CachedDNSToSwitchMapping源代码分析
- 有关tableView和viewControllers的相关
- Android 6.0: 动态权限管理的解决方案
- Android native反调试方式及使用IDA绕过反调试
- Codeforces Round #340 (Div. 2) C. Watering Flowers
- linux 性能测试
- spinner中的onNothingSelected方法到底什么时候调用?
- 小小白初入编程江湖之初入职场迷茫篇
- kmp算法
- wpf 程序异常捕获,而不崩溃退出
- static_cast、dynamic_cast、const_cast和reinterpret_cast总结
- hidesBottomBarWhenPushed导航栏右上角黑块
- UITableViewCell点击时背景颜色