結果
問題 | No.2261 Coffee |
ユーザー |
|
提出日時 | 2023-04-07 22:45:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,159 ms / 2,000 ms |
コード長 | 1,272 bytes |
コンパイル時間 | 2,139 ms |
コンパイル使用メモリ | 205,560 KB |
最終ジャッジ日時 | 2025-02-12 02:08:56 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
#include <bits/stdc++.h>#define rep(i,n) for(int i = 0; i < (n); i++)using namespace std;using ll = long long;using ld = long double;using uint = unsigned int;using ull = unsigned long long;template < class T > bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }template < class T > bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }int main(){cin.tie(0);ios::sync_with_stdio(0);int N; cin >> N;vector<vector<ll>> A(N, vector<ll>(5));rep(i,N)rep(j,5) cin >> A[i][j];vector<int> I;rep(S,1<<5) {vector<ll> sgn(5);rep(j,5) sgn[j] = (S & (1 << j) ? +1 : -1);vector<int> J(N);iota(J.begin(), J.end(), 0);sort(J.begin(), J.end(), [&](int L, int R) {ll sumL = 0, sumR = 0;rep(j,5) {sumL += sgn[j] * A[L][j];sumR += sgn[j] * A[R][j];}return sumL < sumR;});I.push_back(J[0]);I.push_back(J[N - 1]);}rep(k,N) {ll ans = 0;for(int i : I) if(i != k) {ll sum = 0;rep(j,5) sum += abs(A[k][j] - A[i][j]);chmax(ans, sum);}cout << ans << "\n";}}