C - Sagheer and Nubian Market 思路: 二分: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 1000005 #define ll long long ll n,s,ai[maxn],ci[maxn]; inline void in(ll &now) { ; ') Cget=getchar(); +Cget-',Cget=getchar(); } int main() { ;i&…
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost aiEgyptian pounds.…
Sagheer and Nubian Market CodeForces - 812C 题意:n个货物,每个货物基础价格是ai. 当你一共购买k个货物时,每个货物的价格为a[i]+k*i. 每个货物只能购买一次.给你s金币,问你最多可以购买多少个货物,这些货物的最小花费. 题解: 直接二分(1~n)购买数量,每次二分都对每个货物计算价格a[i]+mid*i. 结构体对价格排序,mid个货物总价格大于s的时候break并往小二分,否则往大二分. 数据类型开long long. #include <…
题目描述: Sagheer and Nubian Market time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and re…
C. Sagheer and Nubian Market time limit per test  2 seconds memory limit per test  256 megabytes   On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules.…
C. Sagheer and Nubian Market time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relat…
CF812C Sagheer and Nubian Market 洛谷评测传送门 题目描述 On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains nn different items numbered from 11 to n…
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost aiEgyptian pounds.…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some str…
http://codeforces.com/contest/812/problem/C [题意] 如何花最少的钱买最多的纪念品?首要满足纪念品尽可能多,纪念品数量一样花钱要最少,输出纪念品数量以及最少花费. 纪念品的价钱是这么定义的:,其中a是基价,k是总共要买的纪念品数量,x是纪念品的index. 题目给出各个纪念品的基价a(当然,x也随之确定) [思路] 二分纪念品数量,判断是否满足题意直接贪心,O(n)算出每个纪念品的价钱,O(nlogn)排序,选出最小的mid个: 二分时间复杂度O(n)…