結果
問題 | No.2261 Coffee |
ユーザー |
|
提出日時 | 2023-04-07 22:10:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 680 ms / 2,000 ms |
コード長 | 1,932 bytes |
コンパイル時間 | 4,318 ms |
コンパイル使用メモリ | 257,644 KB |
最終ジャッジ日時 | 2025-02-12 01:31:02 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; typedef long long ll; typedef modint998244353 mint; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<mint> vm; typedef vector<vm> vvm; typedef vector<char> vc; typedef vector<char> vvc; typedef vector<string> vs; typedef vector<vs> vvs; typedef vector<bool> vb; typedef vector<vb> vvb; typedef pair<int, int> pii; typedef pair<int, pii> ppii; typedef pair<ll, ll> pll; typedef pair<ll, pll> ppll; #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define REP_(i, s, t) for (int i = s, i##_len=(t); i<i##_len; ++i) #define ALL(x) x.begin(), x.end() #define SZ(x) (int)x.size() template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } constexpr int MOD = 998244353; constexpr int inf = 1001001001; constexpr ll INF = 1001001001001001001; int main(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20); int N; cin >> N; vvl A(N, vl(5)); REP(i, N) REP(j, 5){ cin >> A[i][j]; } vi ls; REP(i, 1 << 5) { vector<pll> tmp; REP(j, N) { ll s = 0; REP(k, 5){ if (((i >> k) & 1) == 0){ s += A[j][k]; } else { s -= A[j][k]; } } tmp.emplace_back(s, j); } sort(ALL(tmp)); ls.emplace_back(tmp[0].second); ls.emplace_back(tmp[N - 1].second); } REP(k, N){ ll ans = 0; REP(i, 64){ ll s = 0; REP(j, 5){ s += abs(A[k][j] - A[ls[i]][j]); } ans = max(ans, s); } cout << ans << endl; } return 0; }