国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)

2019-11-06 06:33:23
字體:
來源:轉載
供稿:網友
A. Andryusha and Sockstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Andryusha is an orderly boy and likes to keep things in their place.

Today he faced a PRoblem to put his socks in the wardrobe. He has n distinct pairs of socks which are initially in a bag. The pairs are numbered from 1 to n. Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe.

Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time?

Input

The first line contains the single integer n (1?≤?n?≤?105) — the number of sock pairs.

The second line contains 2n integers x1,?x2,?...,?x2n (1?≤?xi?≤?n), which describe the order in which Andryusha took the socks from the bag. More precisely, xi means that the i-th sock Andryusha took out was from pair xi.

It is guaranteed that Andryusha took exactly two socks of each pair.

Output

Print single integer — the maximum number of socks that were on the table at the same time.

Examplesinput
11 1output
1input
32 1 1 3 2 3output
2Note

In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time.

In the second example Andryusha behaved as follows:

Initially the table was empty, he took out a sock from pair 2 and put it on the table.Sock (2) was on the table. Andryusha took out a sock from pair 1 and put it on the table.Socks (1,?2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe.Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table.Socks (2,?3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe.Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe.Thus, at most two socks were on the table at the same time.

題意:先將每雙鞋子的單只鞋子放到桌子上,湊夠一雙放進鞋柜,求桌子上鞋子最多的時候有幾只鞋子。

#include<iostream>#include<cstdio>#include<algorithm>using namespace std;const int N = 100005;int a[N],b[N];int main(){    int n,x;    cin>>n;    int sum = 0,maxn = 1;    for(int i = 0;i < n*2;i++)    {        scanf("%d",&x);        b[x]++;        if(b[x] == 2)            sum--;        else            sum++;        maxn = max(maxn,sum);    }    printf("%d/n",maxn);    return 0;}

B. The Meeting Place Cannot Be Changedtime limit per test5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

The main road in Bytecity is a straight line from south to north. Conveniently, there are coordinates measured in meters from the southernmost building in north direction.

At some points on the road there are n friends, and i-th of them is standing at the point xi meters and can move with any speed no greater than vi meters per second in any of the two directions along the road: south or north.

You are to compute the minimum time needed to gather all the n friends at some point on the road. Note that the point they meet at doesn't need to have integer coordinate.

Input

The first line contains single integer n (2?≤?n?≤?60?000) — the number of friends.

The second line contains n integers x1,?x2,?...,?xn (1?≤?xi?≤?109) — the current coordinates of the friends, in meters.

The third line contains n integers v1,?v2,?...,?vn (1?≤?vi?≤?109) — the maximum speeds of the friends, in meters per second.

Output

Print the minimum time (in seconds) needed for all the n friends to meet at some point on the road.

Your answer will be considered correct, if its absolute or relative error isn't greater than 10?-?6. Formally, let your answer be a, while jury's answer be b. Your answer will be considered correct if  holds.

Examplesinput
37 1 31 2 1output
2.000000000000input
45 10 3 22 3 2 4output
1.400000000000Note

In the first sample, all friends can gather at the point 5 within 2 seconds. In order to achieve this, the first friend should go south all the time at his maximum speed, while the second and the third friends should go north at their maximum speeds.

題意:給你n個人的位置和從每個點出發的最大速度,讓求最少的時間所有的人可以會合。

思路:二分,找接近的時間

#include<iostream>#include<cstdio>#include<algorithm>using namespace std;const double INF = 1e300;const int N = 6e4 + 5;int x[N],v[N];int main(){    int n;    cin >> n;    for(int i = 1;i <= n;i++)        scanf("%d",&x[i]);    for(int i = 1;i <= n;i++)        scanf("%d",&v[i]);    int cnt = 0;    double left = 0,right = 1e9,mid;    while(cnt++ < 123)    {        mid = (left + right) / 2;        double g = -INF,h = INF;        for(int i = 1;i <= n;i++)        {            double p = x[i] - v[i]*mid,q = x[i] + v[i]*mid;            g = max(p,g);            h = min(q,h);        }        if(g <= h)//時間太大了            right = mid;        else//            left = mid;    }    printf("%.10f/n",left);    return 0;}

由于頹廢了一個假期,實在不敢打,先補了兩個題,c、d待


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 北辰区| 南汇区| 农安县| 略阳县| 酒泉市| 金堂县| 玉田县| 双柏县| 沂南县| 瑞昌市| 丹棱县| 宁安市| 汉川市| 贵港市| 平舆县| 斗六市| 石屏县| 镇赉县| 高平市| 白水县| 安泽县| 原平市| 武山县| 姜堰市| 河间市| 盐亭县| 鄯善县| 新巴尔虎右旗| 通道| 孙吴县| 新绛县| 南康市| 宜章县| 仁寿县| 姚安县| 呼伦贝尔市| 义乌市| 肥西县| 靖远县| 通州市| 洪湖市|