結果
問題 |
No.3252 Constrained Moving
|
ユーザー |
|
提出日時 | 2025-09-05 22:15:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 43 ms / 2,000 ms |
コード長 | 570 bytes |
コンパイル時間 | 1,774 ms |
コンパイル使用メモリ | 162,976 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-05 22:15:25 |
合計ジャッジ時間 | 3,917 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:41:14: warning: ‘x’ may be used uninitialized [-Wmaybe-uninitialized] 41 | else if(x==S-1 || x==T-1) cout << -1 << endl; | ^~ main.cpp:28:26: note: ‘x’ was declared here 28 | ll m=10000000000,x; | ^
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; #define REP(i,n) for(ll i=0;i<ll(n);i++) int main(void){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll i,j; ll N,S,T,K; cin >> N >> S >> T >> K; vector<ll> a(N); ll m=10000000000,x; REP(i,N){ cin >> a[i]; if(m>a[i]){ x=i; m=a[i]; } } ll p=a[S-1],q=a[T-1]; if(p+q<=K) cout << 1 << endl; else if(x==S-1 || x==T-1) cout << -1 << endl; else if(m+p<=K && m+q<=K) cout << 2 << endl; else cout << -1 << endl; return 0; }