Submission #8314854
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define repr(i,a,b) for(int i=a;i<b;i++) #define rep(i,n) for(int i=0;i<n;i++) #define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b) #define reprev(i,n) reprrev(i,0,n) typedef long long ll; typedef unsigned long long ull; 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; } /* attention long longのシフト演算には気をつけよう タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも sizeは(int)とキャストしよう cin.tie(0); ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう */ const ll mod = 1e9+7; void chmod(ll &M){ if(M >= mod) M %= mod; else if(M < 0){ M += (abs(M)/mod + 1)*mod; M %= mod; } } ll modpow(ll x, ll n){ if(n==0) return 1; ll res=modpow(x, n/2); if(n%2==0) return res*res%mod; else return res*res%mod*x%mod; } int getl(int i, int N) { return i==0? N-1:i-1; }; int getr(int i, int N) { return i==N-1? 0:i+1; }; // 線分 ab の偏角 返り値は[-π, π] double argument(const pair<double, double> &a, const pair<double, double> &b){ double ax=a.first, ay=a.second, bx=b.first, by=b.second; return atan2(by-ay, bx-ax); } /* <-----------------------------------------------------------------------------------> */ /* <-----------------------------------------------------------------------------------> */ /* <-----------------------------------------------------------------------------------> */ /* <-----------------------------------------------------------------------------------> */ ll n, m; vector<ll> x; void input(){ cin >> n >> m; x.resize(m+1); rep(i, m) cin >> x[i]; x[m] = n+1; } bool check(ll k){ if(k == -1) return false; ll left = 1; for(int i=0; i<m; ++i){ ll right = x[i]; if(x[i]-left > k) return false; while( 2*min(x[i]-left, right-x[i]) + max(x[i]-left, right-x[i]) <= k && right < x[i+1]) ++right; if(i == m-1){ if(right > n) return true; else return false; } else{ left = right; } } cerr << " aaaa " << endl; return false; } void solve(){ ll ng = -1; ll ok = 2e9+5; ll mid; while(ok - ng > 1){ mid = (ok + ng) / 2; if(check(mid)) ok = mid; else ng = mid; } cout << ok << endl; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); input(); solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 壊れた電車 |
User | ose20 |
Language | C++14 (GCC 5.4.1) |
Score | 80 |
Code Size | 2840 Byte |
Status | TLE |
Exec Time | 2103 ms |
Memory | 1024 KB |
Judge Result
Set Name | Sample | Dataset1 | Dataset2 | Dataset3 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 20 / 20 | 60 / 60 | 0 / 20 | ||||||||||
Status |
|
|
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt |
Dataset1 | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt |
Dataset2 | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt, 02-17.txt, 02-18.txt, 02-19.txt |
Dataset3 | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt, 02-17.txt, 02-18.txt, 02-19.txt, 03-01.txt, 03-02.txt, 03-03.txt, 03-04.txt, 03-05.txt, 03-06.txt, 03-07.txt, 03-08.txt, 03-09.txt, 03-10.txt, 03-11.txt, 03-12.txt, 03-13.txt, 03-14.txt, 03-15.txt, 03-16.txt, 03-17.txt, 03-18.txt, 03-19.txt, 03-20.txt, 03-21.txt, 03-22.txt, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 1 ms | 256 KB |
01-02.txt | AC | 1 ms | 256 KB |
01-03.txt | AC | 1 ms | 256 KB |
01-04.txt | AC | 1 ms | 256 KB |
01-05.txt | AC | 1 ms | 256 KB |
01-06.txt | AC | 1 ms | 256 KB |
01-07.txt | AC | 1 ms | 256 KB |
01-08.txt | AC | 1 ms | 256 KB |
01-09.txt | AC | 1 ms | 256 KB |
01-10.txt | AC | 1 ms | 256 KB |
01-11.txt | AC | 1 ms | 256 KB |
01-12.txt | AC | 1 ms | 256 KB |
01-13.txt | AC | 1 ms | 256 KB |
01-14.txt | AC | 1 ms | 256 KB |
01-15.txt | AC | 1 ms | 256 KB |
02-01.txt | AC | 14 ms | 256 KB |
02-02.txt | AC | 6 ms | 256 KB |
02-03.txt | AC | 23 ms | 256 KB |
02-04.txt | AC | 27 ms | 384 KB |
02-05.txt | AC | 64 ms | 1024 KB |
02-06.txt | AC | 43 ms | 640 KB |
02-07.txt | AC | 63 ms | 1024 KB |
02-08.txt | AC | 63 ms | 1024 KB |
02-09.txt | AC | 20 ms | 1024 KB |
02-10.txt | AC | 14 ms | 256 KB |
02-11.txt | AC | 53 ms | 1024 KB |
02-12.txt | AC | 53 ms | 1024 KB |
02-13.txt | AC | 34 ms | 1024 KB |
02-14.txt | AC | 35 ms | 1024 KB |
02-15.txt | AC | 31 ms | 1024 KB |
02-16.txt | AC | 33 ms | 1024 KB |
02-17.txt | AC | 46 ms | 1024 KB |
02-18.txt | AC | 46 ms | 1024 KB |
02-19.txt | AC | 48 ms | 1024 KB |
03-01.txt | TLE | 2103 ms | 256 KB |
03-02.txt | TLE | 2103 ms | 256 KB |
03-03.txt | TLE | 2103 ms | 256 KB |
03-04.txt | TLE | 2103 ms | 1024 KB |
03-05.txt | TLE | 2103 ms | 512 KB |
03-06.txt | TLE | 2103 ms | 640 KB |
03-07.txt | TLE | 2103 ms | 1024 KB |
03-08.txt | TLE | 2103 ms | 1024 KB |
03-09.txt | TLE | 2103 ms | 256 KB |
03-10.txt | TLE | 2103 ms | 1024 KB |
03-11.txt | TLE | 2103 ms | 1024 KB |
03-12.txt | TLE | 2103 ms | 512 KB |
03-13.txt | TLE | 2103 ms | 1024 KB |
03-14.txt | TLE | 2103 ms | 1024 KB |
03-15.txt | TLE | 2103 ms | 1024 KB |
03-16.txt | TLE | 2103 ms | 1024 KB |
03-17.txt | TLE | 2103 ms | 1024 KB |
03-18.txt | TLE | 2103 ms | 1024 KB |
03-19.txt | TLE | 2103 ms | 1024 KB |
03-20.txt | TLE | 2103 ms | 1024 KB |
03-21.txt | TLE | 2103 ms | 1024 KB |
03-22.txt | TLE | 2103 ms | 1024 KB |
sample-01.txt | AC | 1 ms | 256 KB |
sample-02.txt | AC | 1 ms | 256 KB |