CodeForces 620A Professor GukiZ's Robot】的更多相关文章

水题 #include<cstdio> #include<cstring> #include<cmath> #include<stack> #include<vector> #include<string> #include<iostream> #include<algorithm> using namespace std; int sx,sy; int ex,ey; int main() { scanf(&q…
A. Professor GukiZ's Robot   Professor GukiZ makes a new robot. The robot are in the point with coordinates (x1, y1) and should go to the point (x2, y2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrea…
Professor GukiZ and Two Arrays 题解: 将a数组都sort一遍之后, b数组也sort一遍之后. 可以观察得到 对于每一个ai来说, 整个数组bi是一个V型的. 并且对于ai+1的最优解一定是在ai的右边. 然后我们将a数组 和 b数组枚举一遍. 然后再将a数组22组合, b数组22组合之后, 再枚举一遍. 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen("_i…
#include <bits/stdc++.h> using namespace std; + ; const long long inf = 1e18; int n, m; long long suma, sumb; int a[maxn], b[maxn]; long long dbl_a[maxn], dbl_b[maxn]; ], sum_dbl_b[maxn * maxn + ]; int main() { map<int, int> pos_a; scanf("…
D. Professor GukiZ and Two Arrays 题目连接: http://www.codeforces.com/contest/620/problem/D Description Professor GukiZ has two arrays of integers, a and b. Professor wants to make the sum of the elements in the array a sa as close as possible to the sum…
Professor GukiZ and Two Arrays 题意:两个长度在2000的-1e9~1e9的两个序列a,b(无序);要你最多两次交换元素,使得交换元素后两序列和的差值的绝对值最小:输出这个最小的和的差值的绝对值:并且输出交换次数和交换的序号(从1 开始) Input 5 5 4 3 2 1 4 1 1 1 1 Output 1 2 1 1 4 2 策略: 若是只交换一次,直接O(n^2)暴力即可:但是里面可以交换两次..若是分开看..没思路.那就开始时就预处理出同一个序列中任意两个…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. In total there are n piles of…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare…
--睡太晚了. ..脑子就傻了-- 这个题想的时候并没有想到该这样-- 题意大概是有n堆箱子从左往右依次排列,每堆ai个箱子,有m个人,最開始都站在第一个箱子的左边, 每个人在每一秒钟都必须做出两种选择中的一种:1若他的位置有箱子则搬走一个箱子,2往右走一步. 问把全部箱子都搞掉的最少时间-- 非常显然二分一下答案,若为x秒,则每一个人都有x秒.一个一个排出去搬.看是否可以搬完-- 我居然没想到-- #include<map> #include<string> #include&l…
题 题意 两个数列,一个有n个数,另一个有m个数,让你最多交换两次两个数列的数,使得两个数列和的差的绝对值最小,求这个差的绝对值.最少交换次数.交换数对 分析 交换0次.1次可得到的最小的差可以枚举出来. 交换两次,如果枚举就超时了. 我们预处理把第一个数列两两组合的所有情况存储起来为u数组,并且按照大小排序,接着在另一个数列里枚举两个数后,用二分的方法,求交换后使得 差的绝对值最小 的u. 二分查找最接近的值可以用lower_bound函数. 代码 #include<stdio.h> #in…