K - Two Contests】的更多相关文章

题目连接:https://atcoder.jp/contests/agc040/tasks/agc040_b 大佬题解:https://blog.csdn.net/duanghaha/article/details/102892233 题意:有N个问题,每个问题可以由编号L~R之间的人完成,有两个集合S和T,将N个问题放入两个集合中,使得交集和最大 题解与证明 首先找到lmost,与rmin,当区间rmin与lmost在同一个集合中,此时答案为rmin-lmost+1+most_width(最大…
K - Two Contests 原题链接:https://agc040.contest.atcoder.jp/tasks/agc040_b?lang=en 题目大意: 给一个区间集合,将这些区间分为两个集合,求两个区间中线段交集的最大值. 解题思路: 首先找到这些区间的右端点在最左端的区间p,左端点在最右端的区间q. 如果p,q在同一个集合中,那么这个集合的最大交集就是p_r - q_l,而另一个只放一个最大的区间,得到ans1. 如果不在同一个区间,想一下集合区间的特征,含有p的集合S中,区…
Django-Model操作数据库(增删改查.连表结构) 一.数据库操作 1.创建model表        …
题目链接:https://codeforces.ml/gym/102428/attachments/download/9820/statements-en.pdf 题意:构造一个多项式使得外星人编号的函数值小于零,人类的编号函数值大于零. 思路:零点存在问题,我们只要找出字符串中有多少A-H或者H-A的变化就是零点个数,然后利用求多项式板子的代码即可. 1 #include<iostream> 2 #include<algorithm> 3 #include<vector&g…
/* * Main.c * 分支-15. 日K蜡烛图 * Created on: 2014年6月18日 * Author: Boomkeeper ****测试通过***** */ #include <stdio.h> #include <stdlib.h> int main() { float open,close,high,low; scanf("%f %f %f %f",&open,&high,&low,&close); if…
主题链接:http://pat.zju.edu.cn/contests/ds/3-05 给定一系列正整数,请设计一个尽可能高效的算法.查找倒数第K个位置上的数字. 输入格式说明: 输入首先给出一个正整数K.随后是若干正整数,最后以一个负整数表示结尾(该负数不算在序列内.不要处理). 输出格式说明: 输出倒数第K个位置上的数据.假设这个位置不存在,输出错误信息"NULL". 例子输入与输出: 序号 输入 输出 1 4 1 2 3 4 5 6 7 8 9 0 -1 7 2 6 3 6 7…
Hints of sd0061 Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2262    Accepted Submission(s): 673 Problem Description sd0061, the legend of Beihang University ACM-ICPC Team, retired last yea…
http://codeforces.com/contest/1077/problem/E output standard output Polycarp has prepared nn competitive programming problems. The topic of the ii-th problem is aiai, and some problems' topics may coincide. Polycarp has to host several thematic conte…
官方题解:https://media.hihocoder.com/contests/challenge34/tutorials-previewed.pdf 题目链接:http://hihocoder.com/problemset/problem/1781 题意问对于给定序列A,是否存在一个整数k, 使得A冒泡k轮后变成序列B. 这题一种做法是像官方题解一样写个计算区间最值的数据结构. 而我是另一种做法,通过的逆序数 来判断A怎样能变化到B. 例子 首先我举一个例子: 对于序列  A 8 7 5…
Codeforces Round #521 (Div. 3)  E. Thematic Contests 题目传送门 题意: 现在有n个题目,每种题目有自己的类型要举办一次考试,考试的原则是每天只有一种题目类型一种题目类型只能出现在一天每天的题目类型不能相同,而且后一天的题目数量必须正好为前一天的两倍,第一天的题目数量是任意的求怎么安排能使题目尽量多.注意:不是天数尽量多 思路: 首先我们知道一件事,题目属于哪种类型并不重要,重要的是每种类型的个数所以我们先统计出所有类型的个数,存进一个数组,而…
其实一直以来也没有准备在园子里发这样的文章,相对来说,算法改进放在园子里还是会稍稍显得格格不入.但是最近邮箱收到的几封邮件让我觉得有必要通过我的博客把过去做过的东西分享出去更给更多需要的人.从论文刊登后,陆陆续续收到本科生.研究生还有博士生的来信和短信微信等,表示了对论文的兴趣以及寻求算法的效果和实现细节,所以,我也就通过邮件或者短信微信来回信,但是有时候也会忘记回复. 另外一个原因也是时间久了,我对于论文以及改进的算法的记忆也越来越模糊,或者那天无意间把代码遗失在哪个角落,真的很难想象我还会全…
这是一个iOS项目雅黑深邃的K线的绘制. 实现功能包括K线主副图.趋势图.成交量.滚动.放大缩小.MACD.KDJ,长按显示辅助线等功能 预览图 最后的最后,这是项目的开源地址:https://github.com/yate1996/Y_KLine,如果帮到了你,麻烦点赞鼓励鼓励呗~(*^__^*) ~ 欢迎加群讨论其它无关内容…
此算法借用快速排序算法. 这个快速选择算法主要利用递归调用,数组存储方式.包含3个文件,头文件QuickSelect.h,库函数QuickSelect.c,测试文件TestQuickSelect. 其中Cutoff可以自己给定,这个当开始给定的数组(或者递归调用产生的子数组)的元素个数<=20个时,采用插入排序.一般认为当元素个数<=20时,插入排序更快.这个20不是固定的,在这附近浮动都可以的. 头文件QuickSelect.h #ifndef QuickSelect_H #define Q…
3110: [Zjoi2013]K大数查询 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 6050  Solved: 2007[Submit][Status][Discuss] Description 有N个位置,M个操作.操作有两种,每次操作如果是1 a b c的形式表示在第a个位置到第b个位置,每个位置加入一个数c如果是2 a b c形式,表示询问从第a个位置到第b个位置,第C大的数是多少. Input 第一行N,M接下来M行,每行形如1 a…
今天研究了一下这块内容...首先是板子 #include <iostream> #include <stdio.h> #include <math.h> #include <string.h> #include <time.h> #include <stdlib.h> #include <string> #include <bitset> #include <vector> #include <…
Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than k times. Example 1: Input: s = "aaabb", k = 3 Output: 3 The longest substring is "aaa"…
K近邻法(k-nearst neighbors,KNN)是一种很基本的机器学习方法了,在我们平常的生活中也会不自主的应用.比如,我们判断一个人的人品,只需要观察他来往最密切的几个人的人品好坏就可以得出了.这里就运用了KNN的思想.KNN方法既可以做分类,也可以做回归,这点和决策树算法相同. KNN做回归和分类的主要区别在于最后做预测时候的决策方式不同.KNN做分类预测时,一般是选择多数表决法,即训练集里和预测的样本特征最近的K个样本,预测为里面有最多类别数的类别.而KNN做回归时,一般是选择平均…
新的股票绘制粗来啦,欢迎围观star的说(*^__^*) 嘻嘻-- 捏合功能也准备完善了 Github:https://github.com/yate1996/YYStock 长按分时图+五档图 分时图+五档图 长按分时图 分时图 K线图 长按K线图 非全屏嵌入 咦,发现UI好看但是功能好像有点不够用??? 没事,欲求不满的话专业版K线Demo也有♪(^∇^*) 戳这里:https://github.com/yate1996/Y_KLine…
最近在看knn算法,顺便敲敲代码. knn属于数据挖掘的分类算法.基本思想是在距离空间里,如果一个样本的最接近的k个邻居里,绝大多数属于某个类别,则该样本也属于这个类别.俗话叫,"随大流". 简单来说,KNN可以看成:有那么一堆你已经知道分类的数据,然后当一个新的数据进入的时候,就开始跟训练里的每个点求距离,然后挑出离这个数据最近的K个点,看看这K个点属于什么类型,然后用少数服从多数的原则,给新数据归类. 该算法的示意图,简单明了: 下面的算法步骤取自于百度文库(文库是一个好东西),代…
第二小整数 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8299    Accepted Submission(s): 5227 Problem Description 求n个整数中倒数第二小的数.每一个整数都独立看成一个数,比如,有三个数分别是1,1,3,那么,第二小的数就是1.   Input 输入包含多组测试数据.输入的第一行…
#encoding:utf-8 from numpy import * import operator import matplotlib import matplotlib.pyplot as plt from os import listdir def makePhoto(returnMat,classLabelVector): #创建散点图 fig = plt.figure() ax = fig.add_subplot(111) #例如参数为349时,参数349的意思是:将画布分割成3行4…
例题:poj2104 http://poj.org/problem?id=2104 讲解:http://blog.sina.com.cn/s/blog_6022c4720102w03t.html http://seter.is-programmer.com/posts/31907.html 刚刚根据以上2篇博客看懂,还没到写讲解的水平 #include<cstdio> #include<algorithm> using namespace std; ; ],r_child[N*],…
Given integers n and k, find the lexicographically k-th smallest integer in the range from 1 to n. Note: 1 ≤ k ≤ n ≤ 109. Example: Input: n: 13 k: 2 Output: 10 Explanation: The lexicographical order is [1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9], so…
Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The length of num is less than 10002 and will be ≥ k. The given num does not contain any leading zero. Ex…
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix. Note that it is the kth smallest element in the sorted order, not the kth distinct element. Example: matrix = [ [ 1, 5…
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k. Define a pair (u,v) which consists of one element from the first array and one element from the second array. Find the k pairs (u1,v1),(u2,v2) ...(uk,vk) wit…
Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the matrix such that its sum is no larger than k. Example: Given matrix = [ [1, 0, 1], [0, -2, 3] ] k = 2 The answer is 2. Because the sum of rectangle [[0, 1], […
Given a non-empty string str and an integer k, rearrange the string such that the same characters are at least distance k from each other. All input strings are given in lowercase letters. If it is not possible to rearrange the string, return an empt…
Given a non-empty array of integers, return the k most frequent elements. For example,Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may assume k is always valid, 1 ≤ k ≤ number of unique elements.    Your algorithm's time complexity must be…
Given a string, find the length of the longest substring T that contains at most k distinct characters. For example, Given s = “eceba” and k = 2, T is "ece" which its length is 3. 这道题是之前那道Longest Substring with At Most Two Distinct Characters的拓展…