【HDOJ】3473 Minimum Sum】的更多相关文章

划分树解.主席树解MLE. /* 3473 */ #include <iostream> #include <sstream> #include <string> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #include <deque> #include <algorit…
最开始使用递归DP解,stack overflow.化简了一些,复杂度为O(n)就过了. #include <stdio.h> int main() { int case_n, n; int i, j, tmp; int beg, end, sum, max_sum; int number; scanf("%d", &case_n); ; i<=case_n; i++) { scanf("%d", &n); beg = ; tmp…
逆序数的性质.1. 暴力解 #include <stdio.h> #define MAXNUM 5005 int a[MAXNUM]; int main() { int n; int i, j, sum, min; while (scanf("%d", &n) != EOF) { ; i<n; ++i) scanf("%d", &a[i]); sum = ; ; i<n; ++i) { ; j<n; ++j) if (a…
这题目一直wa,原来是因为我把JUDGE写错了,对拍了一下午都没检查出来.水DP啊. #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> #include <iostream> using namespace std; #define MAXN 1020 #define MAXM 35 #define INF 0xfffff int dp[MAX…
题意很简单就是给你一个N和M,让你求在1-N的那些个子序列的值等于M 首先暴力法不解释,简单超时 再仔细想一想可以想到因为1-N是一个等差数列,可以运用我们曾经学过的只是来解决 假设开始的位置为s,结束的位置为t,那么一定要满足这个等式 (s+t)(t-s+1)=2*m 又因为S和T都是整数,所以左边的括号中每一项都是等式 所以s+t和t-s+1一定是2*m的因式 所以分解因式并带入就可以求出s和t 假设 s+t=a t-s+1=b a*b=2*m 解得 s=(a-b+1)/2 t=(a+b-1…
Floyd.注意字典序!!! #include <stdio.h> #include <string.h> #define MAXNUM 55 #define INF 0x1fffffff int cost[MAXNUM][MAXNUM]; int path[MAXNUM][MAXNUM]; int taxes[MAXNUM]; int que[MAXNUM]; int n; void floyd(int n) { int i, j, k, tmp; ; i<=n; ++i)…
题目如下: Given a set of points in the xy-plane, determine the minimum area of any rectangle formed from these points, with sides not necessarily parallel to the x and y axes. If there isn't any rectangle, return 0. Example 1: Input: [[1,2],[2,1],[1,0],[…
[LeetCode]813. Largest Sum of Averages 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/largest-sum-of-averages/description/ 题目描述: We partition a row of numbers A into at most…
[LeetCode]113. Path Sum II 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.me/ 题目地址:https://leetcode.com/problems/path-sum-ii/description/ 题目描述: Given a binary tree and a sum, find all root-to-leaf paths where each…
[LeetCode]452. Minimum Number of Arrows to Burst Balloons 解题报告(Python) 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/description/ 题目描述: There are a number of spherical balloons spread in two-dimensio…