QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#177286 | #6880. Operation Hope | PPP# | AC ✓ | 830ms | 33228kb | C++17 | 1.6kb | 2023-09-12 19:50:36 | 2023-09-12 19:50:36 |
Judging History
answer
#ifdef DEBUG
//#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
#define X first
#define Y second
ll pew(ll a, ll b)
{
ll res = 1;
while (b>0)
{
if (b&1) res = res*a%mod;
b >>= 1;
a = a*a%mod;
}
return res;
}
void solve()
{
int n;
cin >> n;
vector<vector<ll>> a(n*2,vector<ll>(3));
vector<set<pair<ll,ll>>> kek(3);
vector<ll> mx(3);
for (ll i=0;i<n;i++)
{
for (ll j=0;j<3;j++) cin >> a[i][j];
for (ll j=0;j<3;j++) cin >> a[i+n][j];
for (ll j=0;j<3;j++)
{
mx[j] = max(mx[j],a[i][j]);
kek[j].insert({a[i][j],i});
}
}
ll A = mod*mod;
while (true)
{
ll p = -1, D = -1;
for (int j=0;j<3;j++)
{
int w = kek[j].begin()->Y;
if (mx[j]-a[w][j]>D)
{
D = mx[j]-a[w][j];
p = w;
}
}
A = min(A,D);
if (p>=n) break;
for (int j=0;j<3;j++)
{
kek[j].erase({a[p][j],p});
kek[j].insert({a[p+n][j],p+n});
mx[j] = max(mx[j],a[p+n][j]);
}
}
cout << A << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//#ifdef DEBUG
//freopen("input.txt", "r", stdin);
//#endif
int T = 1;
cin >> T;
while (T--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 830ms
memory: 33228kb
input:
99 1000 532114032 55099632 197592060 601440117 964448551 693620489 68503446 149314803 308777541 408078601 977772348 978400861 185066959 236214410 460480442 842502015 709303988 675932475 793016330 161748857 511444978 852914351 281720292 552030608 9982160 15933748 8254470 175080600 567563770 461489051...
output:
982758431 499804923 99919477 99613700 99922111 99914205 99946480 99849310 114469 959350057 499447574 99965775 99807900 99959755 99858165 99900104 99981039 114408 983543586 499348157 99948914 99680790 99821819 99927070 99827404 99854234 114334 984379893 499383664 99973920 99536294 99818752 99826757 9...
result:
ok 99 lines