Codeforces 463A. Caisa and Sugar

Caisa is going to have a party and he needs to buy the ingredients for a big chocolate cake. For that he is going to the biggest supermarket in town.

Unfortunately, he has just s dollars for sugar. But that‘s not a reason to be sad, because there are n types of sugar in the supermarket, maybe he able to buy one. But that‘s not all. The supermarket has very unusual exchange politics: instead of cents the sellers give sweets to a buyer as a change. Of course, the number of given sweets always doesn‘t exceed 99, because each seller maximizes the number of dollars in the change (100 cents can be replaced with a dollar).

Caisa wants to buy only one type of sugar, also he wants to maximize the number of sweets in the change. What is the maximum number of sweets he can get? Note, that Caisa doesn‘t want to minimize the cost of the sugar, he only wants to get maximum number of sweets as change.

Input

The first line contains two space-separated integers n,?s (1?≤?n,?s?≤?100).

The i-th of the next n lines contains two integers xiyi (1?≤?xi?≤?100; 0?≤?yi?<?100), where xi represents the number of dollars and yi the number of cents needed in order to buy the i-th type of sugar.

Output

Print a single integer representing the maximum number of sweets he can buy, or -1 if he can‘t buy any type of sugar.

题目很水,但是理解错了。。。其实糖果就买一个就好

#include <cstdio>
#include <cctype>
#include <stdlib.h>
#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <map>

using namespace std;
typedef long long LL;

int n,s;
int main()
{
  // freopen("test.in","r",stdin);
  cin >> n >> s;
  int res = -1;
  for (int i=0;i<n;i++){
    int dol,cent;
    cin >> dol >> cent;
    if (dol > s || (dol == s && cent > 0)){
      continue;
    }
    int sweet = -1;
    int price = 100*dol + cent;
    // while (price * num <= 100 * s){
    //
    //   // cout << (100*s - price*num) % 100 << endl;
    //   sweet = max(sweet,(100*s - price*num) % 100);
    //   num ++;
    // }
    sweet = (100*s - price) % 100;
    res = max(res,sweet);
  }
  cout << res;
  return 0;
}

时间: 2024-12-26 15:00:45

Codeforces 463A. Caisa and Sugar的相关文章

codeforces A#264. Caisa and Sugar

Caisa is going to have a party and he needs to buy the ingredients for a big chocolate cake. For that he is going to the biggest supermarket in town. Unfortunately, he has just s dollars for sugar. But that's not a reason to be sad, because there are

Codeforce 264 A Caisa and Sugar(简单)

Caisa去商店买Sugar  商店找零的最低单位为元  低于1元的部分每分找一个糖果   商店有n种Suger Caisa有s元钱  她只买一种Sugar  输入n s 再输入n行  每行两个数a b  表示第i种Sugar的单价为a元b分   求Sugar最多能被找多少糖果 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { int n, s

Codeforces 463E Caisa and Tree dfs+分解质因素

题目链接:点击打开链接 题意: 给了一棵树 每个点有点权 操作1 : 1 u 表示询问 gcd(Valueof(u), Valueof(v) ) != 1 的所有v 点中深度最大的点 [ v是 path(u, root); && v!=u ] 操作2 : 2 u w 修改点权 思路: 因为操作2的个数不超过50个,所以每次更新点权后都把所有答案预处理一遍.这样回答是O(1), 更新是n*logn*logn 每次在dfs中计算答案和更新素数栈,dfs完子树后就把这个点在栈里删掉,这样就能保证

Codeforces Round #264 (Div. 2)[ABCDE]

Codeforces Round #264 (Div. 2)[ABCDE] ACM 题目地址: Codeforces Round #264 (Div. 2) 这场只出了两题TAT,C由于cin给fst了,D想到正解快敲完了却game over了... 掉rating掉的厉害QvQ... A - Caisa and Sugar[模拟] 题意: Caisa拿s美元去超市买sugar,有n种sugar,每种为xi美元yi美分,超市找钱时不会找美分,而是用sweet代替,当然能用美元找就尽量用美元找.他

codeforces B#264. Caisa and Pylons

Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during his path. There are (n?+?1) pylons numbered from 0 to n in this game. The pylon with number 0 has zero height, the pylon with numberi

Codeforce 264 B Caisa and Pylons(模拟)

 题意   Caisa走台阶  有n个台阶  第i个台阶的高度为h[i]  从第i个台阶包括地面到下一个台阶得到的能量为h[i]-h[i+1]  能量不足以跳到下一个台阶就要补充能量  求Caisa跳完所有台阶最少要补充多少能量 水题   直接模拟 #include<cstdio> #include<cstring> using namespace std; const int N = 100005; int h[N]; int main() { int n, e, ans;

Codeforces Round #264 (Div. 2) A

题目: Caisa is going to have a party and he needs to buy the ingredients for a big chocolate cake. For that he is going to the biggest supermarket in town. Unfortunately, he has just s dollars for sugar. But that's not a reason to be sad, because there

Codeforces Round #264 (Div. 2) B

题目: B. Caisa and Pylons time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Caisa solved the problem with the sugar and now he is on the way back to home. Caisa is playing a mobile game during

【codeforces 718E】E. Matvey&#39;s Birthday

题目大意&链接: http://codeforces.com/problemset/problem/718/E 给一个长为n(n<=100 000)的只包含‘a’~‘h’8个字符的字符串s.两个位置i,j(i!=j)存在一条边,当且仅当|i-j|==1或s[i]==s[j].求这个无向图的直径,以及直径数量. 题解:  命题1:任意位置之间距离不会大于15. 证明:对于任意两个位置i,j之间,其所经过每种字符不会超过2个(因为相同字符会连边),所以i,j经过节点至多为16,也就意味着边数至多