#include <bits/stdc++.h>
using namespace std;
//#define USACO
#define fi first
#define se second
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define ALL(v) (v).begin(), (v).end()
#define BIT(i) (1LL << (i))
#define MASK(x, i) (((x) >> (i)) & 1)
#define REP(i, v) for( __typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++ i)
#define FORD(i, b, a) for(int i = (b), _a = (a); i >= _a; -- i)
const string NAME = "BAITAP";
const string name = "";
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int mod = 998244353;
const int mxN = 5e5 + 5;
int N, T;
vector<int> A(mxN);
void init(void){
cin >> N >> T;
FOR(i, 1, N) cin >> A[i];
}
namespace subtask_1{
bool check(void){
return N <= 2;
}
void solve(void){
int a = A[1];
int b = A[2];
int ans = INF;
while(a > 0 && b > 0){
int c = a;
a -= T;
ans = min(ans, abs(a - b));
b -= T;
ans = min(ans, abs(b - c));
ans = min(ans, abs(a - b));
}
cout << ans;
}
}
namespace subtask_2{
bool check(void){
return N <= 3000 && T == 1;
}
void solve(void){
cout << 0;
}
}
void process(void){
if(subtask_1::check()) subtask_1::solve();
if(subtask_2::check()) subtask_2::solve();
}
signed main(void){
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef LOCAL
freopen((NAME + ".INP").c_str(), "r", stdin);
freopen((NAME + ".OUT").c_str(), "w", stdout);
#elif defined(USACO)
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
#endif
init();
process();
cerr << "\nTime elapsed: " << TIME << "s.\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |