样例过了,落谷爆0

P3955 [NOIP2017 普及组] 图书管理员

TeaWine @ 2020-11-26 17:09:10

#include <iostream>

#include <algorithm>

using namespace std;

int main () {

    bool e;

int book [10000], ren [10000], o;

int n, q;

cin>>n>>q;

for(int i = 0; i<n; i++) cin>>book [i];

for(int i = 0; i<q; i++) 
{

cin>>o;

cin>>ren [i];

}

sort(book,book+n); //排序 

for(int i = 0; i<q; i++)
{
    e=1;
    for(int p = 0; p<n; p++)
    if(book[p]%10==ren[i]%10&&book[p]!=-1)
    {

        cout << book [p] <<endl;

        book[p] = -1;

        e=0;

        break;
    }
    if(e) cout<<"-1"<<endl;
}

return 0;
}

by A宋锦瑞A @ 2021-07-25 12:16:36

哈喽


by zzxgenius @ 2021-08-04 09:35:19

@cuichenxi2009, book[p] = -1;此题并没有说只有一本书,应删去这行代码


|