結果

問題 No.909 たぴの配置
ユーザー nayutanayuta
提出日時 2019-10-18 21:54:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 743 bytes
コンパイル時間 2,045 ms
コンパイル使用メモリ 176,260 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-07 22:06:28
合計ジャッジ時間 8,198 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int N;
int X[101010], Y[101010];
vector<tuple<int, int, int>> tp;
int ans = 1e9, p[101010];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> Y[i];
  }

  for (int i = 0; i < N; i++) {
    tp.emplace_back(X[i] + Y[i], X[i], Y[i]);
  }

  sort(tp.begin(), tp.end());

  int sum, x, y;
  for (int i = 0; i < N; i++) {
    tie(sum, x, y) = tp[i];
    if (x + y < ans) {
      ans = sum;
    }
    if (x >= ans) {
      p[i] = max(ans - 1, 0);
    } else {
      p[i] = x;
    }
  }

  cout << ans << endl;
  cout << 0 << endl;
  for (int i = 0; i < N; i++) {
    cout << p[i] << endl;
  }
  cout << ans << endl;

  return 0;
}
0