結果

問題 No.909 たぴの配置
コンテスト
ユーザー tanimani364
提出日時 2019-10-19 03:23:36
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,262 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 626 ms
コンパイル使用メモリ 113,636 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-12 17:10:33
合計ジャッジ時間 4,602 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 2 WA * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'void solve()':
main.cpp:55:5: warning: 'minx' may be used uninitialized [-Wmaybe-uninitialized]
   55 |     if(minx>miny)v[i+1]=minv-miny;
      |     ^~
main.cpp:47:16: note: 'minx' was declared here
   47 |   int minv=1e7,minx,miny;
      |                ^~~~
main.cpp:55:5: warning: 'miny' may be used uninitialized [-Wmaybe-uninitialized]
   55 |     if(minx>miny)v[i+1]=minv-miny;
      |     ^~
main.cpp:47:21: note: 'miny' was declared here
   47 |   int minv=1e7,minx,miny;
      |                     ^~~~

ソースコード

diff #
raw source code

#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,minx,miny;
  rep(i,n){
    if(chmin(minv,x[i]+y[i])){
      minx=x[i];miny=y[i];
    }
  }
  v.front()=0;v.back()=minv;
  rep(i,n){
    if(minx>miny)v[i+1]=minv-miny;
    else v[i+1]=minx;
  }
  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