随笔分类 - 贪心
摘要:/* 贪心的找到相邻两项差的最大值,再减去c,结果若是负数答案为0. */ 1 #include 2 #define maxn 105 3 int num[maxn]; 4 int main() 5 { 6 int n,c; 7 while(~scanf("%d%d",&n,&c)) 8 { 9 int ans = 0;10 for(int i = 0;i ans)15 ans = temp;16 }17 ans -= c;18 if(ans>=0...
阅读全文
摘要:题目:http://acm.hdu.edu.cn/showproblem.php?pid=4522建两个图,分别用dijstra。#include<stdio.h>#include<iostream>#include<string.h>#include<math.h>#include<string>#include<algorithm>#pragma comment(linker, "/STACK:1024000000,1024000000")using namespace std;const int
阅读全文
摘要:http://www.acmore.net/problem.php?id=1504利用优先队列,转化成O(m)的复杂度。#include <iostream>#include <stdio.h>#include <string>#include <string.h>#include <algorithm>#include <math.h>#include <fstream>#include <vector>#include <map>#include <queue>#incl
阅读全文

浙公网安备 33010602011771号