結果

問題 No.909 たぴの配置
ユーザー tanimani364tanimani364
提出日時 2019-10-19 03:31:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 54 ms / 3,000 ms
コード長 1,253 bytes
コンパイル時間 867 ms
コンパイル使用メモリ 89,920 KB
実行使用メモリ 5,476 KB
最終ジャッジ日時 2023-09-08 10:44:26
合計ジャッジ時間 3,820 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 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 AC 52 ms
5,476 KB
testcase_06 AC 53 ms
5,396 KB
testcase_07 AC 49 ms
5,120 KB
testcase_08 AC 54 ms
5,408 KB
testcase_09 AC 54 ms
5,476 KB
testcase_10 AC 50 ms
5,088 KB
testcase_11 AC 50 ms
5,116 KB
testcase_12 AC 52 ms
5,348 KB
testcase_13 AC 54 ms
5,444 KB
testcase_14 AC 50 ms
5,080 KB
testcase_15 AC 49 ms
5,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

void solve(){
  int n;
  cin>>n;
  vector<int>v(n+2),x(n),y(n);
  rep(i,n)cin>>x[i];
  rep(i,n)cin>>y[i];
  int minv=1e7;
  rep(i,n){
    chmin(minv,x[i]+y[i]);
  }
  v.front()=0;v.back()=minv;
  for(int i=1;i<=n;++i){
    if(x[i-1]>y[i-1])v[i]=max(0,minv-y[i-1]);
    else v[i]=min(v.back(),x[i-1]);
  }
  cout<<minv<<"\n";
  for(int z:v)cout<<z<<"\n";
  return;
}
 
signed main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
  cout<<fixed<<setprecision(20);
	solve();
	return 0;
}
0