結果

問題 No.3252 Constrained Moving
ユーザー Gia Quyết
提出日時 2025-09-05 21:26:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 934 bytes
コンパイル時間 2,060 ms
コンパイル使用メモリ 195,508 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-05 21:26:35
合計ジャッジ時間 4,084 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int32_t main()’:
main.cpp:32:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |         freopen(TASKNAME ".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:33:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |         freopen(TASKNAME ".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define db double
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b / __gcd(a,b)
#define I first
#define II second
#define pb push_back
#define ii pair<int,int>
const int INF = 2 * 1e18;
const int N = 3e5 + 1;
const int MOD = 1e9 + 7;    

void solve() {
    int n, s, t, k;
    cin >> n >> s >> t >> k;
    vector<int> a(n + 1);
    int mn = INF;
    for (int i = 1; i <= n; i++) cin >> a[i], mn = min(mn, a[i]);
    if (a[s] + a[t] <= k) cout << 1 << '\n'; else 
    if (a[s] + mn <= k && a[t] + mn <= k) cout << 2 << '\n'; else 
        cout << -1 << '\n';
}
int32_t main()
{
    #define TASKNAME "test"
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if (fopen(TASKNAME ".inp","r" ))
    {
        freopen(TASKNAME ".inp","r",stdin);
        freopen(TASKNAME ".out","w",stdout);
    }
    int t = 1; 
    //cin >> t;
    while (t--) solve();
    return 0;
}
0