用map为啥只有60分啊

P1478 陶陶摘苹果(升级版)

颜鹏炜 @ 2019-11-22 10:05:37

#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
    long long n,s,a,b,num[5050], liqi[5050],sum=0;
    map<long long,long long>paixu;
    cin >> n >> s;
    cin >> a >> b;
    for(int i=1;i<=n;++i) {
        cin >> num[i] >> liqi[i];
        paixu[liqi[i]] = num[i];
    }
    sort(liqi + 1, liqi + n+1);

    for (int i = 1; i <= n; ++i)
    {
        if (paixu[liqi[i]] - b - a <= 0&&s-liqi[i]>=0)
        {
            sum++;
            s=s-liqi[i];
        }
        cout << liqi[i] <<"  "<<paixu[liqi[i]]<< endl;
    }
    cout << sum ;
}

by 白厶冯弓吿氵 @ 2019-11-22 10:14:53

重复的力气呢?


by 白厶冯弓吿氵 @ 2019-11-22 10:15:41

就被忽略了


by 颜鹏炜 @ 2019-11-22 13:23:34

@履带大怪物 ?不太理解


by 白厶冯弓吿氵 @ 2019-11-22 13:37:51

试一下这个数据:

3 10
5 3
1 2
2 2
3 2
4 2
9 2

by 白厶冯弓吿氵 @ 2019-11-22 13:38:11

力气是不是重复了


|