首页 > TAG信息列表 > mmin

Day4.(每日一题)B. Buggy Robot(C语言)

#include <stdio.h> int min(int a,int b) { int mmin=a; if(b<mmin) mmin=b; return mmin; } int main() { char s[101]; int n,i,x,y,x1=0,x2=0,y1=0,y2=0; scanf("%d %s",&n,&s); for(i=0;i<n;i++) { if(s[i]=='U') y

【leetcode】1026. Maximum Difference Between Node and Ancestor

   Given the root of a binary tree, find the maximum value v for which there exist different nodes a and b where v = |a.val - b.val| and a is an ancestor of b. A node a is an ancestor of b if either: any child of a is equal to b or a

cf1607 G. Banquet Preparations 1(贪心)

https://codeforces.com/contest/1607/problem/G 题意: 给定数组a[],b[]和整数m。每个盘子里有ai个白球和bi个黑球。现要从每个盘子里拿走m个球,使得剩下的所有白球的和与所有黑球的和的差的绝对值最小。题目保证每个盘子里的球数不少于m 思路: 假设从每个盘子里拿 \(x_i\) 个白球和

Educational Codeforces Round 109 D. Armchairs (dp)

传送门 题意:有一个长度为n的0/1数列,1的个数小于等于0的个数,可以把i位置上的1移到j位置(如果j位置是0),i位置变成0,j位置变成1,代价是|i-j|,问使得所有原先是1的位置都变成0的代价最小是多少。 (3<=n<=5000) 分析:我们可以把1/0的下标都拿出来,放进数组pos1\pos0里面,问题就变成了拿