ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#212257 | #3811. T1 | sublimetext | 50 | 121ms | 1320kb | C++11 | 1.5kb | 2024-10-13 16:10:36 | 2024-10-13 19:37:07 |
answer
#include <bits/stdc++.h>
using namespace std;
#define LL __int128
#define ll long long
#define uLL __uint128_t
#define ull unsigned long long
#define REP(i, l, r) for(int i = l; i <= r; ++i)
#define PER(i, r, l) for(int i = r; i >= l; --i)
namespace ink {
const int N = 2e6+5;
int Q;
struct A{
int op,d,x,y;
} q[N];
struct node {
int x,y;
bool operator < (const node&it) const {
return x+y==it.x+it.y?x + y < it.x + it.y:x < it.x;
}
};
multiset<node> S[2];
struct Tnode {
int x, y;
bool operator < (const Tnode&it) const {
return x != it.x ? x < it.x : y < it.y;
}
};
multiset<Tnode> T[2];
int main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin>>Q;
int O = (int)2e8 / Q;
REP(i,1,Q) {
cin>>q[i].op>>q[i].d>>q[i].x>>q[i].y;
if(q[i].op==1) {
S[q[i].d].insert({q[i].x,q[i].y});
T[q[i].d].insert({q[i].x,q[i].y});
}
else {
S[q[i].d].erase(S[q[i].d].find({q[i].x,q[i].y}));
T[q[i].d].erase(T[q[i].d].find({q[i].x,q[i].y}));
}
if(S[0].empty()||S[1].empty()) {
cout<<-1<<'\n';
continue;
}
int ans=max(S[0].begin()->x+S[1].begin()->x, S[0].begin()->y+S[1].begin()->y);
ans=min(ans,
max(T[0].begin()->x+T[1].begin()->x, T[0].begin()->y+T[1].begin()->y));
for(auto&i:S[0]) {
int CNT = 0;
for(auto&j:S[1]) {
ans=min(ans,max(i.x+j.x,i.y+j.y));
++CNT;
if(CNT >= O) break;
}
}
cout<<ans<<'\n';
}
return 0;
}
}
signed main() {return ink::main();}
Details
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 1268kb
input:
100 1 0 30056910 791979446 0 0 30056910 791979446 1 1 87818006 915325879 1 0 885405412 638527154 0 1...
output:
-1 -1 -1 1553853033 -1 -1 -1 1372223954 1160777349 1160777349 787718936 787718936 1160777349 -1 -1 -...
result:
ok 100 numbers
Subtask #2:
score: 10
Accepted
Test #2:
score: 10
Accepted
time: 0ms
memory: 1268kb
input:
100 1 0 888145469 920169409 1 0 452904566 455699108 1 0 9314511 72429163 0 0 452904566 455699108 1 1...
output:
-1 -1 -1 -1 560615725 560615725 560615725 560615725 560615725 738065491 738065491 1439446683 8215374...
result:
ok 100 numbers
Subtask #3:
score: 10
Accepted
Test #3:
score: 10
Accepted
time: 40ms
memory: 1316kb
input:
1000 1 0 434052041 886975755 1 0 5735137 42531708 1 0 333067530 62734547 0 0 434052041 886975755 1 1...
output:
-1 -1 -1 -1 839243210 831398858 1022941456 1158731251 462065303 462065303 -1 -1 407960422 407960422 ...
result:
ok 1000 numbers
Subtask #4:
score: 10
Accepted
Test #4:
score: 10
Accepted
time: 40ms
memory: 1320kb
input:
1000 1 1 99608765 102738517 1 0 409526489 651778959 1 1 632469167 447766999 1 1 596595729 295223176 ...
output:
-1 754517476 754517476 754517476 754517476 754517476 240180556 240180556 240180556 240180556 7545174...
result:
ok 1000 numbers
Subtask #5:
score: 10
Accepted
Test #5:
score: 10
Accepted
time: 41ms
memory: 1320kb
input:
1000 1 1 392884476 341683390 1 1 812391583 884023296 0 1 392884476 341683390 0 1 812391583 884023296...
output:
-1 -1 -1 -1 -1 -1 -1 1033130556 -1 -1 596121801 596121801 572006216 572006216 572006216 572006216 57...
result:
ok 1000 numbers
Subtask #6:
score: 0
Time Limit Exceeded
Test #6:
score: 0
Time Limit Exceeded
input:
200000 1 0 745208991 893565181 1 1 338915529 332862800 1 1 879402360 343669571 0 0 745208991 8935651...
output:
-1 1226427981 1226427981 -1 1156522405 1156522405 907552725 851482156 851482156 851482156 851482156 ...
result:
Subtask #7:
score: 0
Time Limit Exceeded
Test #7:
score: 0
Time Limit Exceeded
input:
200000 1 0 61288090 442363511 1 0 702180888 491607485 0 0 702180888 491607485 0 0 61288090 442363511...
output:
-1 -1 -1 -1 -1 1369535428 1182928863 1182928863 -1 568524713 568524713 568524713 568524713 548209901...
result:
Subtask #8:
score: 0
Time Limit Exceeded
Test #8:
score: 0
Time Limit Exceeded
input:
200000 1 0 965089945 885763418 1 0 47734550 558904612 0 0 47734550 558904612 1 0 511007140 115554736...
output:
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 770546713 770546713 1082209730 1082209730 1082209730 1082209730 108...
result:
Subtask #9:
score: 0
Time Limit Exceeded
Test #9:
score: 0
Time Limit Exceeded
input:
1000000 1 1 598963903 48224788 1 0 880787238 21153517 1 0 874812562 609964051 0 1 598963903 48224788...
output:
-1 1479751141 1473776465 -1 -1 1484975949 1433383436 1331359936 1074242658 865998205 865998205 86599...
result:
Subtask #10:
score: 0
Time Limit Exceeded
Test #10:
score: 0
Time Limit Exceeded
input:
1000000 1 0 532848699 733617288 1 1 59884418 599409867 0 1 59884418 599409867 1 0 1137393 496603003 ...
output:
-1 1333027155 -1 -1 1118403184 1355417469 1355417469 1140899234 1085347521 1078478006 1085347521 672...