結果

問題 No.909 たぴの配置
ユーザー tanimani364tanimani364
提出日時 2019-10-19 03:23:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,262 bytes
コンパイル時間 756 ms
コンパイル使用メモリ 91,584 KB
実行使用メモリ 5,576 KB
最終ジャッジ日時 2023-09-08 10:25:55
合計ジャッジ時間 5,431 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:55:29: warning: ‘miny’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(minx>miny)v[i+1]=minv-miny;
                         ~~~~^~~~~
main.cpp:55:5: warning: ‘minx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(minx>miny)v[i+1]=minv-miny;
     ^~

ソースコード

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,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