Submission #19392745


Source Code Expand

Copy
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define ld long double

#define rep(i, n) for(int i = 0; i < n; ++i)
#define rep2(i, a, b) for(int i = a; i <= b; ++i)
#define rrep(i, a, b) for(int i = a; i >= b; --i)

#define pii pair<int, int>
#define pll pair<ll, ll>

#define fi first
#define se second

#define pb push_back
#define eb emplace_back

#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi(a,b,c,d) vector<vector<int>> a(b,vector<int>(c,d));
#define vvll(a,b,c,d) vector<vector<ll>> a(b,vector<ll>(c,d));

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define endl '\n'
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1000000007;
//const int MOD=998244353;
const ll INF = 1e18+1;
const int inf = 1e9+1;
const double PI = acos(-1);
int dx[8] = {1, 0, -1,  0,  1, 1, -1, -1};
int dy[8] = {0, 1,  0, -1, -1, 1,  1, -1};
bool range(int y, int x, int h, int w){
  if(y < 0 || x < 0 || y >= h || x >= w) return false;
  else return true;
}

const int MAX = 310000;


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  cout << fixed << setprecision(10);
  
  ll n, m;
  cin >> n >> m;
  
  
  ll ans = 0;
  rep2(i,1,1000000000){
    ll bus = (n*i+m-1)/m;
    chmax(ans, bus*m-n*i);
  }
  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task D - Bus Tour
User cumin
Language C++ (GCC 9.2.1)
Score 0
Code Size 1705 Byte
Status TLE
Exec Time 2205 ms
Memory 3316 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
TLE × 3
TLE × 28
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_2.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
Case Name Status Exec Time Memory
sample_01.txt TLE 2205 ms 3232 KB
sample_02.txt TLE 2205 ms 3184 KB
sample_03.txt TLE 2205 ms 3244 KB
subtask_1_1.txt TLE 2205 ms 3188 KB
subtask_1_10.txt TLE 2205 ms 3128 KB
subtask_1_11.txt TLE 2205 ms 3188 KB
subtask_1_12.txt TLE 2205 ms 3308 KB
subtask_1_13.txt TLE 2205 ms 3256 KB
subtask_1_14.txt TLE 2205 ms 3128 KB
subtask_1_15.txt TLE 2205 ms 3184 KB
subtask_1_16.txt TLE 2205 ms 3312 KB
subtask_1_17.txt TLE 2205 ms 3224 KB
subtask_1_18.txt TLE 2205 ms 3316 KB
subtask_1_19.txt TLE 2205 ms 3236 KB
subtask_1_2.txt TLE 2205 ms 3176 KB
subtask_1_20.txt TLE 2205 ms 3128 KB
subtask_1_21.txt TLE 2205 ms 3128 KB
subtask_1_22.txt TLE 2205 ms 3236 KB
subtask_1_23.txt TLE 2205 ms 3232 KB
subtask_1_24.txt TLE 2205 ms 3232 KB
subtask_1_25.txt TLE 2205 ms 3188 KB
subtask_1_3.txt TLE 2205 ms 3192 KB
subtask_1_4.txt TLE 2205 ms 3248 KB
subtask_1_5.txt TLE 2205 ms 3172 KB
subtask_1_6.txt TLE 2205 ms 3316 KB
subtask_1_7.txt TLE 2205 ms 3296 KB
subtask_1_8.txt TLE 2205 ms 3128 KB
subtask_1_9.txt TLE 2205 ms 3248 KB