codeforces590b//Chip 'n Dale Rescue Rangers//Codeforces Round #327 (Div. 1)
题意:从一点到另一点,前t秒的风向与t秒后风向不同,问到另一点的最短时间
挺难的,做不出来,又参考了别人的代码。先得到终点指向起点的向量,设T秒钟能到。如果T>t则受风1作用t秒,风2作用T-t秒,否则只受风1作用t秒。风作用对向量的影响加到向量上。如果该向量长度小于(船速*T)^2的话,说明T秒能到。T实际上用low和high的mid得出,如果T秒可行,则提高下限。
乱码:
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include <stack>
#include <ctime>
#include <iomanip>
using namespace std;
const int SZ=,INF=0x7FFFFFFF; void sort(vector<int> &vct,int lo,int hi)
{
if(lo>=hi)return;
int i=lo,j=hi-;
int pivot=rand()%(hi-lo)+lo;
//cout<<lo<<" "<<hi<<" "<<pivot<<endl;
int val=vct[pivot];
for(;i<j;)
{
for(;i<j&&j>pivot;--j)
{
if(abs(vct[j])<abs(vct[pivot]))
{
swap(vct[j],vct[pivot]);
pivot=j;
break;
}
}
for(;i<j&&i<pivot;++i)
{
if(abs(vct[i])>abs(vct[pivot]))
{
swap(vct[i],vct[pivot]);
pivot=i;
break;
}
}
}
//cout<<pivot<<endl;
//cout<<vct[0]<<" "<<vct[1]<<" "<<vct[2]<<" "<<vct[3]<<endl;
sort(vct,lo,pivot);
sort(vct,pivot+,hi);
} int main()
{
std::ios::sync_with_stdio();
//freopen("d:\\1.txt","r",stdin);
int n;
for(;cin>>n,n;)
{
vector<int> vct(n);
for(int i=;i<n;++i)
{
cin>>vct[i];
}
sort(vct,,vct.size());
for(int i=n-;i>=;--i)
{
if(i!=n-)cout<<" ";
cout<<vct[i];
}
cout<<endl;
}
return ;
}
codeforces590b//Chip 'n Dale Rescue Rangers//Codeforces Round #327 (Div. 1)的更多相关文章
- Codeforces Round #327 (Div. 2) D. Chip 'n Dale Rescue Rangers 二分 物理
D. Chip 'n Dale Rescue Rangers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/co ...
- Codeforces Round #327 (Div. 1) B. Chip 'n Dale Rescue Rangers 二分
题目链接: 题目 B. Chip 'n Dale Rescue Rangers time limit per test:1 second memory limit per test:256 megab ...
- codeforces 590B B. Chip 'n Dale Rescue Rangers(二分+计算几何)
题目链接: B. Chip 'n Dale Rescue Rangers time limit per test 1 second memory limit per test 256 megabyte ...
- cf590B Chip 'n Dale Rescue Rangers
B. Chip 'n Dale Rescue Rangers time limit per test 1 second memory limit per test 256 megabytes inpu ...
- Codeforces Round #327 590B Chip 'n Dale Rescue Rangers(等效转换,二分)
t和可到达具有单调性,二分就不多说了.下面说下O(1)的做法,实际上是等效转换,因为答案一定存在,如果在t0之前,那么分解一下 直接按照只有v计算就可以了.反过来如果计算的结果大于t0,那么表示答案在 ...
- CodeForces 590B Chip 'n Dale Rescue Rangers
这题可以o(1)推出公式,也可以二分答案+验证. #include<iostream> #include<cstring> #include<cmath> #inc ...
- Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题
A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...
- Codeforces Round #327 (Div. 2) E. Three States BFS
E. Three States Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/probl ...
- Codeforces Round #327 (Div. 2) C. Median Smoothing 找规律
C. Median Smoothing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/p ...
随机推荐
- topcoder srm 663 div1
problem1 link 每次枚举$S$的两种变化,并判断新的串是否是$T$的子串.不是的话停止搜索. problem2 link 首先考慮增加1个面值为1的硬币后,$ways$数组有什么变化.设原 ...
- Python3 tkinter基础 Entry insert delete 点击按钮 向输入框赋值 或 清空
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Android系统分区理解及分区目录细解【转】
本文转载自:https://blog.csdn.net/u010001503/article/details/51853822 Android 通常有以下分区: System分区: 就是我们刷ROM的 ...
- centos6.5下安装jdk并配置环境变量
链接: https://blog.csdn.net/wawawawawawaa/article/details/81158943 以下链接供参考: https://blog.csdn.net/Bugg ...
- mybatis批量更新数据参考
https://blog.csdn.net/xyjawq1/article/details/74129316
- function CONVERSION_EXIT ****INPUT/OUTPUT说明
CONVERSION_EXIT_ALPHA_INPUT和CONVERSION_EXIT_ALPHA_OUTPUT 函数说明 CONVERSION_EXIT_MATN1_INPUT 物料号码转换函数 C ...
- 【Python】【有趣的模块】【Requests】session & cookie
保存http请求的状态(请求的上下文) [区别&联系] 1. cookie保存在客户端的浏览器,比如标识是哪个请求者.购物车应用等 session保存在服务端,http连接时无则创建,有则用现 ...
- 详解JS中DOM 元素的 attribute 和 property 属性
一.'表亲戚':attribute和property 为什么称attribute和property为'表亲戚'呢?因为他们既有共同处,也有不同点. attribute 是 dom 元素在文档中作为 h ...
- centos7 Python3终端中敲击方向键显示「^[[C^[[D」
[root@localhost src]# python3 Python ( , ::) [GCC (Red Hat -)] on linux Type "help", " ...
- 对前台传过来的实体是否为空 进行为空校验的N种方法
首先定义一个注解,如下 import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import j ...