Problem ID :d077. 4.排隊

New Thread

User 請問能否提供測資4的資料嗎?

hslin SendIMessage
hslin001

d077. 4.排隊 | From: 1.168.223.186 | Post Date:2021-08-27 22:06:04.0

謝謝

#include <iostream>

using namespace std;

#include <algorithm>

struct t{

int q;

int s;

};

#include <queue>

 

bool cmp(t s1,t s2){

return s1.q < s2.q;

}

int main(){

int n;

cin >> n;

t a[n];

queue<int> m;

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

cin >> a[i].q >> a[i].s;

}

 

sort(a,a+n,cmp);

 

int l=0,k=0,max = 0;

    l = a[0].q + a[0].s;

    m.push(l);

for(int i=1;i<n;i++){

        while (a[i].q > m.front() && !m.empty()){

            m.pop();

        }

 

        l = a[i].q + a[i].s;

        m.push(l);

        if (max < m.size()) max = m.size();

}

if (max < m.size()) max = m.size();

cout << max-1 << endl;

}

 

 


文章類型: 一般 | Reply | Back
User Re:請問能否提供測資4的資料嗎?

sagit SendIMessage
sagit

d077. 4.排隊 | From: 112.104.149.52 | Post Date:2021-08-28 08:24:41.0

測資4:

25
0 1
0 2
0 2
1 2
3 2
5 2
8 3
9 3
9 1
9 3
9 1
10 3
11 2
12 3
13 1
13 2
13 1
13 2
15 3
15 1
17 2
18 1
18 1
19 1
20 1

 


文章類型: 一般 | Reply | Back

New Thread

ZeroJudge Forum