Tên đăng nhập Điểm ▾ Bài tập Giới thiệu
281 360 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;

}

282
huuthinh222010
Nguyễn Hữu Thịnh
83 7
283
tancuong2010 1196
Nguyễn Tấn Cường
59 18
284 55 1
285
tranthiquynhngann 573
Trần Thị Quỳnh Ngân
48 15
286 48 12
287
hoangmang 1263
lê văn hoàng
46 10

l̶̸̴̶̸̵̶̵̶̵̶̴̴̢̢̨̡̧̡̛̮̻̘̱͈̘͇̟̭̥̠̻͉̪͉͎͉̘̤̘͓͉͔̣͔̳͉̦̱̹̳̠̦̦͉̖̹̺̩̟̠̣̭̖͕̥̺͓̜̭̺͚̠͉̝̦̘̗͈̱̻̣̱̳̮̬͕͓͓̱͙͈̝̟͈͖̗̣͒̐͛́̃̅̊̂̈́̇̈́̋̓̾͛̀̈́͊̉̌͋̀͌̑̅̌͐͗̇̏̀͌̑̉̈́̉͆̿͂̀͛̇̒̌́̿̈͊͋̉́̉̈̏͛̄̏̏̾̔̕̚̚͘͜͜͜͝͝͝͝ͅͅ
ư̷̶̸̵̶̷̴̵̶̸̸̡̨̧̨̨̛̼̲͙̬̣̬̯͚̟̺͔͈̣̣̘̩͓̣̗͓̰͍͔̼͚̯̞͙̲̰͍̝̣̭̹͎̙̘̼̗̼̼̺͖̭͙̩̠̥͌̊́̂͐̈̆̄͂̍̾̏̈́̀̓̀͌̈́̌̀̃͛͑̅̆̉̑͂̓́͊͂̿̀̔̃͐̐̏̒̿̒͌͗̇̋̚͜͝͠͝
ṭ̷̴̴̶̶̵̵̴̨̧̨̛̮͕̝͔̮̥̣̫̯̫̰̖̳̳̯̙̰͎̦̰̪̻̳̞͕̘̲̜͇͚͕͙̍͆̎͆̓̇̋̀͒͊͊͂̅͊̏̌̇͑͆̊͐̈̏̿̆͐̔̌̆̚̚͘͝͝
ḙ̵̴̴̶̵̸̶̶̷̶̷̷̵̸̶̸̢̢̨̧̨̨̨̝̠̠͔̳͎̣̹̬̟̗̱͍̱̩͉̱͕͎̙̝̺͓̰̜͚͉̞̜̲̬̬͍͖̣͈̣͈̱̹͔̤̬̲̗̤̝̹̣̦̥͚̠̝̮̱͈̬͇̯̞̙̖̦̪͉̹͓̼̻̹̦̼̖̽̊̓̋̉̏̒̆̉̄́̌̂͋̿́̏̌̄͛̐̿̆̊̍̿̈̀̍̀͋̅̏̊̐͛̾͋̑͆̅̆̅̔̑͌́̂̈́͗͌͋̾̌̓̒̕̕͘̕͜͝͝͝͠ͅ
l̸̸̴̵̸̷̶̸̵̴̴̸̡̡̡̡̡̛̛̛̛͔̱̲̥̱̟̰̦̥͈̳̘̱̗̺̲͍̝̺̻̬͔͎̤̼̟̪͈͈̞̠͔̰̭͔̫̤̲̪͈̼͚͚̞͙͎̣̥͕͓̮̥̤̰̖̦̬̙̳̤͖̻̹̱̼̣̘̍͂̈̋͋̇̍̎͒̀͑́̉̾͐͌̔̏̾̏̈́̔̄̐̈́̄́̑͆͐̀͗̇͋̓̌̈̔̀̇̇̑̆͌̂̌̉̓̚͜͝͝͠͝͝͝͝͝ͅͅ
y̸̴̸̷̸̶̶̴̴̷̷̶̵̶̸̷̷̴̡̢̨̢̨̨̛̬̭̱̠͕̬͓͙̲̺̖̠̩̝̞̤̺̝̲̝͚̗̺̙͎̘̣̳̖̙͚̲̺̣̭̯͓̝͚̤͉͈̙̬͙͖͚͓̫̰̙̘̼̜̩̲͇̳͕̦͍͚̲̹̼͖̭̳̯͓̣̦̱͚̝̰̝̻̼̗̮̳͓̣̟̦̰̯͎̬̱̞̗̞̥̩̳͕̳̳̙̐̎̓̈́͆̓̀͋̄̂̑͋̈́̊̈́͂̄̍̎͌͗͌̍͑́͗̈́͑͂͆͛͐̓̄̃̎̀̿̀͊̎̾̾̈̀̑̔̊̊́̈̿̓̂̾́̏̏̈́̾̔͑̑͑̏̿͋́̆̿͋̚̚̕̕͜͜͝͝͝͠͝͝ͅ
ą̸̴̷̵̴̷̴̸̴̷̴̧̡̨̨̺͚̟̫̭͉͈̘̝̜̫͎̳̜͖̠̞̫̱̖̦̻̝̘̟̰͕̗͖̣̩͔͇̫̙͎͈̦̪̣̞̝̻̦͓͖̌͊̀̍̄͑̌̽̈́̊̂͌̂̊̿̎̈̍͋̈́͂̋͂̊̿͛̈́͋̀̎̓͆̀͆̊̏̋̔̿̑͑͋́̎̓̑̍̏̃̈́̿̕̚͘͝͝͝͝͝
b̸̷̶̶̴̷̴̴̶̵̢̨̧̢̢̛̠͉͉͙̞͚͕͇͍͙̤̮̜̯̠͔͙̖̳̺̳̻̙̱͎̥͔̳̠͕̝̠̣̭̗̹͇̤̺̦͕͎̙͙͙̳͕̲̘̥̩̜̟͈̩̼͖̼̞̖̼̝̩̘̺̙͚̮͗͒̔͊̐̓̅̿̏͒̿̈́̅̎͒͛̈́̉̑̃́̍̓́̑̄̊̔̈́͑͋̒̔̂͒̓̌̂͌͗̆̊̌͆͑̐̃̆̂̀̀̃̈́
s̵̴̴̵̴̴̴̶̵̶̷̷̸̷̷̶̸̸̢̡̢̡̢̧̛̛̩̺̣̱̱̠̹̪̼̮̰̩̫̱̱̬͔̪̹͎͓̫̜͈͍̘̟͕̖̪̪͍̗̦̪̯̥̪̹̫̳͓̝͈̜̮͎̘͈̥̣̖̝̰̯̗̦̗̹̱̺̗̝̱̙̠̱̖̱͚̯̞̞̠̳̝̪̽͐̃̆̑̋̄̀̊̎͗́̍̔̂͆͆̊͂̾̏̍͒́͑͗̄͋̄͑͋͑̽̈́̊̔͛̃̉̋͗̇́̑̈́͒̌̆̿̉̓̈̆͑̀̓̽̈́̊̐̒̽̏̓̄̌͌͑͐̑̏͗́̂̓̋̒́̆̅̏̓̓̃͗̓̓́̎̈́̉̃̋͌̀̒̋̊́͒̀̏̈́̆̊̕͘͘͘͜͝͠͝͝͝͝͝͝͝͠ͅͅ
ơ̸̵̵̸̷̶̶̵̴̸̵̷̵̴̷̶̡̧̨̨̡̛̮͈̫̪͍͇͖͈̠̦̲̣͔͍̤͖͇̠̞͚͇͙̦͇̮̬͇͔͉̻͚̥̱̱͔̘̘͙̯̖̣̫̣̝̤̻͚͍̞͍̮̱̲̙̲̹̰̭̳̭̭͉̏͆̂́̇̿̈́́̃̿̑͋͊͆̒̂̀̈̋͌̎̓́̿̋̓̎̀̈́̍͛̋̿̓̓̉̐̔͋̽̐̆̐̊͑͗́̇̈́̿̀̀͑͊̃̽̅̽͂̍͒͊̓͊́͘̕͘̕̚͘͜͜͝͝͠͝͠͝͝͝ͅͅ
l̶̸̴̶̸̵̶̵̶̵̶̴̴̢̢̨̡̧̡̛̮̻̘̱͈̘͇̟̭̥̠̻͉̪͉͎͉̘̤̘͓͉͔̣͔̳͉̦̱̹̳̠̦̦͉̖̹̺̩̟̠̣̭̖͕̥̺͓̜̭̺͚̠͉̝̦̘̗͈̱̻̣̱̳̮̬͕͓͓̱͙͈̝̟͈͖̗̣͒̐͛́̃̅̊̂̈́̇̈́̋̓̾͛̀̈́͊̉̌͋̀͌̑̅̌͐͗̇̏̀͌̑̉̈́̉͆̿͂̀͛̇̒̌́̿̈͊͋̉́̉̈̏͛̄̏̏̾̔̕̚̚͘͜͜͜͝͝͝͝ͅͅ
ư̷̶̸̵̶̷̴̵̶̸̸̡̨̧̨̨̛̼̲͙̬̣̬̯͚̟̺͔͈̣̣̘̩͓̣̗͓̰͍͔̼͚̯̞͙̲̰͍̝̣̭̹͎̙̘̼̗̼̼̺͖̭͙̩̠̥͌̊́̂͐̈̆̄͂̍̾̏̈́̀̓̀͌̈́̌̀̃͛͑̅̆̉̑͂̓́͊͂̿̀̔̃͐̐̏̒̿̒͌͗̇̋̚͜͝͠͝
ṭ̷̴̴̶̶̵̵̴̨̧̨̛̮͕̝͔̮̥̣̫̯̫̰̖̳̳̯̙̰͎̦̰̪̻̳̞͕̘̲̜͇͚͕͙̍͆̎͆̓̇̋̀͒͊͊͂̅͊̏̌̇͑͆̊͐̈̏̿̆͐̔̌̆̚̚͘͝͝
ḙ̵̴̴̶̵̸̶̶̷̶̷̷̵̸̶̸̢̢̨̧̨̨̨̝̠̠͔̳͎̣̹̬̟̗̱͍̱̩͉̱͕͎̙̝̺͓̰̜͚͉̞̜̲̬̬͍͖̣͈̣͈̱̹͔̤̬̲̗̤̝̹̣̦̥͚̠̝̮̱͈̬͇̯̞̙̖̦̪͉̹͓̼̻̹̦̼̖̽̊̓̋̉̏̒̆̉̄́̌̂͋̿́̏̌̄͛̐̿̆̊̍̿̈̀̍̀͋̅̏̊̐͛̾͋̑͆̅̆̅̔̑͌́̂̈́͗͌͋̾̌̓̒̕̕͘̕͜͝͝͝͠ͅ
l̸̸̴̵̸̷̶̸̵̴̴̸̡̡̡̡̡̛̛̛̛͔̱̲̥̱̟̰̦̥͈̳̘̱̗̺̲͍̝̺̻̬͔͎̤̼̟̪͈͈̞̠͔̰̭͔̫̤̲̪͈̼͚͚̞͙͎̣̥͕͓̮̥̤̰̖̦̬̙̳̤͖̻̹̱̼̣̘̍͂̈̋͋̇̍̎͒̀͑́̉̾͐͌̔̏̾̏̈́̔̄̐̈́̄́̑͆͐̀͗̇͋̓̌̈̔̀̇̇̑̆͌̂̌̉̓̚͜͝͝͠͝͝͝͝͝ͅͅ
y̸̴̸̷̸̶̶̴̴̷̷̶̵̶̸̷̷̴̡̢̨̢̨̨̛̬̭̱̠͕̬͓͙̲̺̖̠̩̝̞̤̺̝̲̝͚̗̺̙͎̘̣̳̖̙͚̲̺̣̭̯͓̝͚̤͉͈̙̬͙͖͚͓̫̰̙̘̼̜̩̲͇̳͕̦͍͚̲̹̼͖̭̳̯͓̣̦̱͚̝̰̝̻̼̗̮̳͓̣̟̦̰̯͎̬̱̞̗̞̥̩̳͕̳̳̙̐̎̓̈́͆̓̀͋̄̂̑͋̈́̊̈́͂̄̍̎͌͗͌̍͑́͗̈́͑͂͆͛͐̓̄̃̎̀̿̀͊̎̾̾̈̀̑̔̊̊́̈̿̓̂̾́̏̏̈́̾̔͑̑͑̏̿͋́̆̿͋̚̚̕̕͜͜͝͝͝͠͝͝ͅ

288
Nguyen_thi_phuong_nhi10 1034
Nguyễn Thị Phương Nhi
45 10
289
NhoEderson 1161
Võ Quang Nho
43 12

290 42 8
291 37 6
292 36 11
293
no 1561
36 9
294 36 6
295 35 7
296 34 9
297 34 6
298 33 7
299 29 6
300 29 9