Tên đăng nhập Điểm ▾ Bài tập Giới thiệu
221 1201 1
221 1201 1
221 1201 1
221 1201 1
221 1201 1
221 1201 1

include <bits/stdc++.h>

define task "PPOINT"

define ll long long

define fi first

define se second

define pb push_back

using namespace std;

const int N = 1e6 + 5;
int n, cnt[5], ans = INT_MAX, l = 1, r = 1;
pair<int, int> p[N];

main() {
cin.tie(0)->sync_with_stdio(0);
if(fopen(task ".INP", "r")) {
freopen(task ".INP", "r", stdin);
freopen(task ".OUT", "w", stdout);
}

cin >> n;
for(int i = 1; i <= n; i++) {
    cin >> p[i].fi >> p[i].se;
}

sort(p + 1, p + n + 1);

while(l <= n && r <= n) {
    cnt[p[r].se]++;
    while(cnt[1] > 0 && cnt[2] > 0 && cnt[3] > 0 && l < r) {
        ans = min(ans, p[r].fi - p[l].fi);
        cnt[p[l].se]--;
        l++;
    }
    r++;
}

cout << ans;

return 0;

}

227 1140 9

.

228
tuannanhh 1217
đỗ tuấn anh
1131 42
229 1101 1
229 1101 1
229
namdeptrai
Nguyễn Lương Hải Nam
1101 1
229 1101 1
229 1101 1
229 1101 1
235 1097 29

anh la quang hoi hoi bn cua mark troc va tantrunghoi
come back with c++
code bai PHAO CHUOI IV

236
nduc0308 1317
Mai Nguyên Đức
1082 25
237 1032 11
238 1014 3
239 1012 4
240 1001 1