一. 题目 1. Two Sum II Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the ta…
一. 题目 1. Two SumTotal Accepted: 241484 Total Submissions: 1005339 Difficulty: Easy Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solutio…
food评测传送门 [题目描述] 叫外卖是一个技术活,宅男宅女们一直面对着一个很大的矛盾,如何以有限的金钱在宿舍宅得尽量久. 外卖店一共有 N 种食物,每种食物有固定的价钱 Pi 与保质期 Si ,保质期的意义是食物会在被买的第 Si 天后过期.譬如你在今天叫了一个 Si =1 的食物,则你必须在今天或者明天吃掉它. 现在你有 M 元钱,每次叫外卖需要 F 元的运费,送外卖的小哥身强体壮,叫一次可以帮你带来任意份任意种食物,请问在保证每天都吃到至少一份未过期食物的前提下,你最多能宅…
D. Exams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasiliy has an exam period which will continue for n days. He has to pass exams on m subjects. Subjects are numbered from 1 to m. Ab…
题目传送门 题意:有多个矩形分布在[0, 0]到[R, R]的的范围内,画一条竖线分割成两块矩形,使得左边包括矩形的面积大于等于右边的面积,在这个前提下使得画的竖线尽量远 分析:二分答案,当面积相等时,判断再往右一个单位是否还可以相等,若不行则答案唯一确定,否则可以往右移动,即最后的竖线要不在一个矩形内或者在矩形边缘时最优. #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e4…
题目链接: B. Skills time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Lesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was…
The Revenge of the Princess’ Knight Problem Description There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his people. Now he is jus…
思路:这里就要看往那边贪心了,因为解决的是最大值最小化,最小值最大化.也就是说当满足大于等于c时,l=mid+1这样的二分得到的就是在所有满足条件函数下的最右端. #include<iostream> #include<algorithm> using namespace std; #define ll long long ; int a[maxn], n, maxx, ans; ll c, mid; bool check(ll x){ ll sum = ; ; i <= n…
The main city magazine offers its readers an opportunity to publish their ads. The format of the ad should be like this: There are space-separated non-empty words of lowercase and uppercase Latin letters. There are hyphen characters '-' in some words…