結果
問題 |
No.909 たぴの配置
|
ユーザー |
![]() |
提出日時 | 2019-10-18 21:57:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 744 bytes |
コンパイル時間 | 1,981 ms |
コンパイル使用メモリ | 175,384 KB |
実行使用メモリ | 7,272 KB |
最終ジャッジ日時 | 2024-06-25 15:58:38 |
合計ジャッジ時間 | 10,136 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 WA * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair<int,int> P; const int INF = 1e9; int main(){ int n; cin >> n; vector<int> x(n),y(n); rep(i,n) cin >> x[i]; rep(i,n) cin >> y[i]; vector<P> tapi; rep(i,n) { tapi.push_back({x[i],y[i]}); } sort(tapi.begin(),tapi.end()); vector<int> res(n+2); res[0] = 0; res[1] = tapi[0].first; res[n+1] = tapi[0].second + tapi[0].first; for (int i = 2; i <= n; i++) { if (tapi[i-1].second < res[n+1] - res[1]) res[i] = res[n+1] - tapi[i-1].second; else res[i] = res[1]; } cout << res[n+1] << endl; for (auto e : res) { cout << e << endl; } return 0; }