結果

問題 No.2259 Gas Station
ユーザー twooimp2
提出日時 2024-03-29 18:12:19
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 25,061 ms
コンパイル使用メモリ 351,456 KB
最終ジャッジ日時 2025-02-20 14:36:17
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;

void IO(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
}

int main(){
  IO();
  ll l,r,c;
  cin>>l>>r>>c;
  if((r-l+1)>=1000){
    cout<<0<<endl;
    exit(0);
  }
  ll ans=1e18;
  for(ll i=l;i<=r;i++){
    ll num=i*c;
    ll tmp=(num+1000-1)/1000;
    ans=min(ans,1000*tmp-num);
  }
  cout<<ans<<endl;
}
0