Jeff got 2n real numbers a1, a2, ..., a2n as a birthday present. The boy hates non-integer numbers, so he decided to slightly "adjust" the numbers he's got. Namely, Jeff consecutively executes n operations, each of them goes as follows:

  • choose indexes i and j (i ≠ j) that haven't been chosen yet;
  • round element ai to the nearest integer that isn't more than ai (assign to ai: ⌊ ai ⌋);
  • round element aj to the nearest integer that isn't less than aj (assign to aj: ⌈ aj ⌉).

Nevertheless, Jeff doesn't want to hurt the feelings of the person who gave him the sequence. That's why the boy wants to perform the operations so as to make the absolute value of the difference between the sum of elements before performing the operations and the sum of elements after performing the operations as small as possible. Help Jeff find the minimum absolute value of the difference.

Input

The first line contains integer n (1 ≤ n ≤ 2000). The next line contains 2n real numbers a1, a2, ..., a2n (0 ≤ ai ≤ 10000), given with exactly three digits after the decimal point. The numbers are separated by spaces.

Output

In a single line print a single real number — the required difference with exactly three digits after the decimal point.

Examples
Input

Copy
3
0.000 0.500 0.750 1.000 2.000 3.000
Output

Copy
0.250
Input

Copy
3
4469.000 6526.000 4864.000 9356.383 7490.000 995.896
Output

Copy
0.279
Note

In the first test case you need to perform the operations as follows: (i = 1, j = 4), (i = 2, j = 3), (i = 5, j = 6). In this case, the difference will equal |(0 + 0.5 + 0.75 + 1 + 2 + 3) - (0 + 0 + 1 + 1 + 2 + 3)| = 0.25.

假设小数部分是x的话,向下取整为-x,向上为1-x;

可以发现不论是向下还是向上都是 -x,那么小数部分就可以统一处理;

那么问题就是当向上取整时,会+1----->求1的个数;

那么枚举就行了;

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 200005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-3
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
ll x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
ll sqr(ll x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ int n;
int m; int main() {
//ios::sync_with_stdio(0);
cin >> n;
m = 2 * n;
double tmp;
int numeq = 0;
double sum = 0.0;
int numdb = 0;
for (int i = 1; i <= m; i++) {
rdlf(tmp);
ll intmp = (ll)tmp;
if (intmp == tmp)numeq++;
else {
sum += 1.0*(tmp - intmp);
numdb++;
}
}
int minn = min(n, numeq);
double ans = inf;
for (int i = 0; i <= minn; i++) {
ans = min(ans, (double)fabs(n - i - sum));
}
printf("%.3lf\n", 1.0*ans);
return 0;
}

最新文章

  1. CSS3按钮效果
  2. Linux----LVM扩容磁盘空间
  3. [转载]Python 资源大全
  4. 远程桌面Default.rdp 中各个参数的含义(转)
  5. iOS边练边学--iOS中的json数据解析
  6. python-twisted系列(1)
  7. ViewData,ViewBag和TempData
  8. UNIX时间戳与日期的相互转换
  9. 深入探索C++对象模型-语义
  10. 大话git中的撤销操作
  11. javascript第五章--函数表达式
  12. React Native学习(四)—— 写一个公用组件(头部)
  13. vmstat结果在不同操作系统上的解释
  14. 一次ES故障排查过程
  15. RESTful规范1
  16. boost--时间处理
  17. 桌面输入法评测报告 之 搜狗拼音输入法vs必应拼音输入法
  18. 解决ASP.NET MVC4中使用Html.DropDownListFor显示枚举值默认项问题
  19. java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
  20. js同步 异步 运行机制

热门文章

  1. Python函数(六)-嵌套函数
  2. 11-13SQLserver基础--数据库之事务
  3. Shell编程进阶 1.5 if逻辑判断
  4. python之Dict和set类型
  5. js 中的apply
  6. lucene、solr中的日期衰减方法-------function query --尚未测试在solr4.8
  7. day70-oracle PLSQL_01基本语法
  8. elasticsearch2.x优化小结(单节点)
  9. Swing事件机制
  10. 算法Sedgewick第四版-第1章基础-022一QueueWithTwoStacks