zoukankan      html  css  js  c++  java
  • cf 463A

    A. Caisa and Sugar
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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.

    Sample test(s)
    input
    5 10
    3 90
    12 0
    9 70
    5 50
    7 0
    output
    50
    input
    5 5
    10 10
    20 20
    30 30
    40 40
    50 50
    output
    -1
    Note

    In the first test sample Caisa can buy the fourth type of sugar, in such a case he will take 50 sweets as a change.

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<cmath>
    #include<cstdlib>
    #include<algorithm>
    using namespace std;
    int n,s;
    int x[110],y[110];
    int main()
    {
          int ans=-1;
          scanf("%d%d",&n,&s);
          for(int i=1;i<=n;i++)
                scanf("%d%d",&x[i],&y[i]);
          for(int i=1;i<=n;i++)
          {
                if(x[i]<s)
                      ans=max(ans,(100-y[i])%100);
                if(x[i]==s&&y[i]==0)
                      ans=max(ans,0);
          }
          printf("%d
    ",ans);
          return 0;
    }
    

      

  • 相关阅读:
    不要轻易相信ALV
    什么是SAP Note?如何打SAP Note?
    BW作为源系统连接时,激活DSO或其他模型时提示8*数据源不存在,无法激活
    MDX Parser问题导致BO无法连通BW的解决方案
    BW中跳转报表参数传递
    SD、MM转换BI CONTENT激活错
    如何加载经过许可的第三方断字符
    把SQL Server 错误日志导出为EXCEL 并发送到指定的ftp 或者 共享盘
    tsql 调用作业
    SQL Server 2005 维护计划无法保存
  • 原文地址:https://www.cnblogs.com/a972290869/p/4240674.html
Copyright © 2011-2022 走看看