QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#850124 | #3610. Kangaroo Party | LaVuna47# | AC ✓ | 0ms | 3844kb | C++20 | 1.7kb | 2025-01-09 20:39:46 | 2025-01-09 20:39:48 |
Judging History
answer
/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, st_, n) for(int i = st_; i < n; ++i)
#define RFOR(i, n, end_) for(int i = (n)-1; i >= end_; --i)
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
int solve()
{
int n;
if(!(cin>>n))return 1;
vector<ll> a(n);
FOR(i,0,n) cin>>a[i];
ll res=1e18;
FOR(i,0,n)
{
FOR(j,i+1,n)
{
ll cur_res=0;
FOR(k,0,n)
{
cur_res += min((a[k]-a[i])*(a[k]-a[i]), (a[k]-a[j])*(a[k]-a[j]));
}
res=min(cur_res, res);
}
}
cout<<res<<"\n";
return 0;
}
int32_t main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int TET = 1e9;
//cin >> TET;
for (int i = 1; i <= TET; i++)
{
if (solve())
{
break;
}
#ifdef ONPC
cout << "__________________________" << endl;
#endif
}
#ifdef ONPC
cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3684kb
input:
5 0 3 -3 10 11
output:
19
result:
ok single line: '19'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
20 735 730 -668 -882 -607 -731 854 -992 -218 -897 591 -512 -306 314 552 -477 961 -574 -717 -106
output:
1151907
result:
ok single line: '1151907'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
17 741 -988 -613 58 79 -715 406 965 -843 373 471 588 624 992 -785 531 692
output:
1034075
result:
ok single line: '1034075'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
3 492 -681 -309
output:
138384
result:
ok single line: '138384'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
38 -865 473 174 -399 729 805 751 -710 298 -748 -906 -444 -237 366 -782 -331 -454 150 -205 53 156 -909 973 -103 22 -847 -927 374 740 -548 521 545 -881 -74 7 -691 701 -139
output:
3314504
result:
ok single line: '3314504'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
40 -407 -301 -657 -734 766 -692 -681 819 -294 715 -280 -470 -187 -926 772 -269 347 -871 191 970 501 -729 494 -980 176 874 -318 305 -494 294 -11 -37 -537 917 267 -703 65 -957 203 955
output:
3425636
result:
ok single line: '3425636'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
26 428 -257 483 832 -129 -791 -618 -480 -748 745 274 314 355 -529 -458 963 918 787 -671 404 -34 -839 -611 -120 272 -805
output:
1822321
result:
ok single line: '1822321'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
12 210 675 3 -388 -401 869 -540 -656 871 275 -877 615
output:
877576
result:
ok single line: '877576'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
48 419 521 386 839 502 807 404 -41 -144 -373 -21 647 387 465 -703 -328 -947 881 735 -670 929 -777 -669 431 661 642 -550 -538 583 389 860 -204 837 657 890 68 178 488 -293 624 -306 282 385 358 280 208 176 922
output:
3049859
result:
ok single line: '3049859'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
16 -388 194 749 -626 824 871 230 -778 -349 -885 -59 471 -963 -584 117 -649
output:
1236727
result:
ok single line: '1236727'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
15 -930 -650 375 -693 -972 88 -575 -623 393 817 -433 -805 -851 -799 -357
output:
657048
result:
ok single line: '657048'