結果

問題 No.2261 Coffee
ユーザー cumincumin
提出日時 2023-04-08 06:57:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 305 ms / 2,000 ms
コード長 4,323 bytes
コンパイル時間 4,616 ms
コンパイル使用メモリ 279,952 KB
実行使用メモリ 26,752 KB
最終ジャッジ日時 2024-10-03 03:55:47
合計ジャッジ時間 14,145 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 1 ms
5,248 KB
testcase_04 AC 2 ms
5,248 KB
testcase_05 AC 1 ms
5,248 KB
testcase_06 AC 1 ms
5,248 KB
testcase_07 AC 1 ms
5,248 KB
testcase_08 AC 2 ms
5,248 KB
testcase_09 AC 1 ms
5,248 KB
testcase_10 AC 1 ms
5,248 KB
testcase_11 AC 2 ms
5,248 KB
testcase_12 AC 2 ms
5,248 KB
testcase_13 AC 1 ms
5,248 KB
testcase_14 AC 1 ms
5,248 KB
testcase_15 AC 2 ms
5,248 KB
testcase_16 AC 2 ms
5,248 KB
testcase_17 AC 9 ms
5,248 KB
testcase_18 AC 9 ms
5,248 KB
testcase_19 AC 9 ms
5,248 KB
testcase_20 AC 8 ms
5,248 KB
testcase_21 AC 10 ms
5,248 KB
testcase_22 AC 9 ms
5,248 KB
testcase_23 AC 11 ms
5,248 KB
testcase_24 AC 276 ms
24,952 KB
testcase_25 AC 236 ms
21,888 KB
testcase_26 AC 291 ms
26,444 KB
testcase_27 AC 273 ms
24,704 KB
testcase_28 AC 112 ms
22,784 KB
testcase_29 AC 98 ms
22,400 KB
testcase_30 AC 78 ms
18,176 KB
testcase_31 AC 132 ms
26,752 KB
testcase_32 AC 133 ms
26,624 KB
testcase_33 AC 134 ms
26,624 KB
testcase_34 AC 132 ms
26,684 KB
testcase_35 AC 132 ms
26,624 KB
testcase_36 AC 134 ms
26,624 KB
testcase_37 AC 134 ms
26,624 KB
testcase_38 AC 298 ms
26,624 KB
testcase_39 AC 298 ms
26,624 KB
testcase_40 AC 305 ms
26,624 KB
testcase_41 AC 302 ms
26,696 KB
testcase_42 AC 299 ms
26,624 KB
testcase_43 AC 303 ms
26,624 KB
testcase_44 AC 293 ms
26,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/extc++.h>
//#include<atcoder/all>
 
using namespace std;
//using namespace atcoder;

#define ll long long
#define ld long double
#define ull unsigned long long
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _rep1(n) for(ll i = 0; i < n; ++i)
#define _rep2(i, n) for(ll i = 0; i < n; ++i)
#define _rep3(i, a, b) for(ll i = a; i < b; ++i)
#define _rep4(i, a, b, c) for(ll i = a; i < b; i += c)
#define rep(...) _overload4(__VA_ARGS__, _rep4, _rep3, _rep2, _rep1)(__VA_ARGS__)
#define rrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define rrep2(i, a, b) for(int i = (a)-1; i >= b; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define eb emplace_back
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define endl '\n'
//using Bint = __int128_t;
template<class T> using pq = priority_queue< T >;
template<class T> using pqg = priority_queue< T , vector< T >, greater< T >>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>
T ceil_div(T a, T b) {
    if(b < 0) a = -a, b = -b;
    return (a >= 0 ? (a + b - 1) / b : a / b);
}
 
template<class T>
T floor_div(T a, T b) {
    if(b < 0) a = -a, b = -b;
    return (a >= 0 ? a / b : (a - b + 1) / b);
}
inline ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll digit(ll x){
  string s = to_string(x);
  return (ll)s.size();
}

const int inf = 1001001001;
const ll INF = 1001001001001001001;

const double PI = acos(-1);

bool range(ll y, ll x, ll h, ll w){
  return (0 <= y && y < h && 0 <= x && x < w);
}
int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};

//using mint = modint998244353;
//const int MOD = 998244353;
//using mint = modint1000000007;
const int MOD = 1000000007;

template<class T> vector< T > compress(vector< T > a){
  auto b = a;
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  int n = a.size();
  for(auto& x : a) x = lower_bound(b.begin(), b.end(), x) - b.begin();
  return a;
}
pair<vector<int>, vector<int>> bfs(vector<vector<int>> &G, int s){
  int n = G.size();
  vector<int> dist(n, inf);
  vector<int> from(n, -1);
  dist[s] = 0;
  queue<int> que;
  que.push(s);
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(int nv : G[v]){
      if(dist[nv] != inf) continue;
      dist[nv] = dist[v] + 1;
      from[nv] = v;
      que.push(nv);
    }
  }
  return {dist, from};
}
ll modpow(ll a, ll n, ll mod){
  if(n == 0)return 1;
  if(n%2 == 0){
    ll t = modpow(a, n/2, mod);
    return (t*t)%mod;
  }
  return a*modpow(a, n-1, mod)%mod;
}
pair<vector<ll>, vector<int>> dijkstra(vector<vector<pll>> &G, int s){
  int n = G.size();
  vector<ll> dist(n, INF);
  vector<int> prev(n, -1);
  dist[s] = 0;
  pqg<pll> que;
  que.push({0, s});
  while(!que.empty()){
    auto[c, v] = que.top();
    que.pop();
    if(dist[v] != c) continue;
    for(auto[nv, add] : G[v]){
      if(dist[nv] > dist[v] + add){
        dist[nv] = dist[v] + add;
        prev[nv] = v;
        que.push({dist[nv], nv});
      }
    }
  }
  return {dist, prev};
}
void Yes(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
}
signed main(){

  cout << fixed << setprecision(15);
  
  int n;
  cin >> n;
  vector<vector<ll>> v(n, vector<ll>(5));
  rep(i, n)rep(j, 5) cin >> v[i][j];
  
  vector<vector<ll>> d(n, vector<ll>(16));
  
  rep(i, n){
    rep(bit, 1<<4){
      ll sum = v[i][0];
      rep(j, 4){
        if(bit >> j & 1) sum += v[i][j+1];
        else sum -= v[i][j+1];
      }
      d[i][bit] = sum;
    }
  }
  vector<vector<ll>> m(1<<4, vector<ll>(2));
  rep(i, 1<<4){
    m[i][0] = INF;
    m[i][1] = -INF;
  }
  rep(i, n){
    rep(j, 1<<4){
      chmin(m[j][0], d[i][j]);
      chmax(m[j][1], d[i][j]);
    }
  }
  
  rep(i, n){
    ll ans = 0;
    rep(j, 1<<4){
      chmax(ans, abs(d[i][j] - m[j][0]));
      chmax(ans, abs(d[i][j] - m[j][1]));
    }
    cout << ans << endl;
  }
  return 0;
}
0