problem_id
stringlengths
6
6
language
stringclasses
2 values
original_status
stringclasses
3 values
original_src
stringlengths
19
243k
changed_src
stringlengths
19
243k
change
stringclasses
3 values
i1
int64
0
8.44k
i2
int64
0
8.44k
j1
int64
0
8.44k
j2
int64
0
8.44k
error
stringclasses
270 values
stderr
stringlengths
0
226k
p03161
Python
Time Limit Exceeded
n, k, *L = map(int, open(0).read().split()) # dp = [float("inf")] * n dp = [0] * n for i in range(1, n): j = max(0, i - k) dp[i] = min([DP + abs(L[i] - COST) for DP, COST in zip(dp[j:i], L[j:i])]) print(dp[-1])
n, k, *L = map(int, open(0).read().split()) # dp = [float("inf")] * n dp = [0] * n for i in range(1, n): j = max(0, i - k) e = L[i] dp[i] = min([DP + abs(e - COST) for DP, COST in zip(dp[j:i], L[j:i])]) print(dp[-1])
replace
7
8
7
9
TLE
p03161
Python
Runtime Error
N, K = map(int, input().split()) h = list(map(int, input().split())) inf = 10**9 dp = [inf] * N dp[0] = 0 def chmin(num: int, sbn: int): dp[num + sbn] = min((dp[num + sbn], dp[num] + abs(h[i + sbn] - h[num]))) for i in range(N): for sbn in range(K): try: chmin(dp, i, sbn + 1) exc...
N, K = map(int, input().split()) h = list(map(int, input().split())) inf = 10**9 dp = [inf] * N dp[0] = 0 def chmin(num: int, sbn: int): dp[num + sbn] = min((dp[num + sbn], dp[num] + abs(h[i + sbn] - h[num]))) for i in range(N): for sbn in range(K): try: chmin(i, sbn + 1) except ...
replace
14
15
14
15
TypeError: chmin() takes 2 positional arguments but 3 were given
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03161/Python/s825976309.py", line 15, in <module> chmin(dp, i, sbn + 1) TypeError: chmin() takes 2 positional arguments but 3 were given
p03161
Python
Time Limit Exceeded
n, k = map(int, input().split()) h = tuple(map(int, input().split())) INF = 10**10 dp = [INF] * n dp[0] = 0 # dp[i] = (足場iにたどり着いた時点でのコストの最小値) for i in range(n): for j in range(i + 1, min(i + k + 1, n)): if dp[j] > dp[i] + abs(h[j] - h[i]): dp[j] = dp[i] + abs(h[j] - h[i]) print(dp[n - 1])
n, k = map(int, input().split()) h = tuple(map(int, input().split())) INF = 10**10 dp = [INF] * n dp[0] = 0 # dp[i] = (足場iにたどり着いた時点でのコストの最小値) for i in range(1, n): dp[i] = min(dp[j] + abs(h[j] - h[i]) for j in range(max(0, i - k), i)) print(dp[n - 1])
replace
8
12
8
10
TLE
p03161
Python
Runtime Error
N, K = map(int, input().split()) H = list(map(int, input().split())) dp = [1 << 62] * N dp[0] = 0 for i in range(1, N): for j in range(i, min(i + 1 + K, N)): cost = abs(H[i - 1] - H[i + j]) dp[i + j] = min(dp[i + j], dp[i - 1] + cost) print(dp[-1])
N, K = map(int, input().split()) H = list(map(int, input().split())) dp = [1 << 62] * N dp[0] = 0 for i in range(1, N): for j in range(i, min(i + K, N)): cost = abs(H[i - 1] - H[j]) dp[j] = min(dp[j], dp[i - 1] + cost) print(dp[-1])
replace
5
8
5
8
IndexError: list index out of range
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03161/Python/s787574815.py", line 7, in <module> cost = abs(H[i - 1] - H[i + j]) IndexError: list index out of range
p03161
Python
Time Limit Exceeded
n, k = map(int, input().split()) h = list(map(int, input().split())) a = [0] * n a[0] = 0 for i in range(1, n): a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)]) print(a[-1])
def main(): n, k = map(int, input().split()) h = list(map(int, input().split())) a = [0 for i in range(n)] for i in range(1, n): a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)]) print(a[-1]) if __name__ == "__main__": main()
replace
0
7
0
11
TLE
p03161
Python
Time Limit Exceeded
from math import inf n, k = map(int, input().split()) a = [int(i) for i in input().split()] dp = [inf for _ in range(n)] dp[0] = 0 for i in range(1, n): for j in range(1, k + 1): if i - j >= 0: dp[i] = min(dp[i], abs(a[i] - a[i - j]) + dp[i - j]) print(dp[-1])
from math import inf n, k = map(int, input().split()) a = [int(i) for i in input().split()] dp = [inf for _ in range(n)] dp[0] = 0 for i in range(1, n): for j in range(1, k + 1): if i - j >= 0: dp[i] = min(dp[i], abs(a[i] - a[i - j]) + dp[i - j]) else: break print(dp[-1])
insert
10
10
10
12
TLE
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define MOD ((int)(1e9) + 7) #define fast \ cin.tie(0); \ cout.tie(0); ...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define MOD ((int)(1e9) + 7) #define fast \ cin.tie(0); \ cout.tie(0); ...
replace
34
35
34
35
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define ff first #define ss second #define ll long long #define ll_MAX LONG_LONG_MAX #define ll_MIN LONG_LONG_MIN #define pi pair<int, int> #define endl "\n" #define MAXN 100005 #define mod 1000000007 using namespace std; void solve() {} int main() { ...
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define ff first #define ss second #define ll long long #define ll_MAX LONG_LONG_MAX #define ll_MIN LONG_LONG_MIN #define pi pair<int, int> #define endl "\n" #define MAXN 100005 #define mod 1000000007 using namespace std; void solve() {} int main() { ...
replace
33
34
33
35
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long add(long long a, long long b) { long long res = a + b; if (res >= mod) res -= mod; return res; } long long sub(long long a, long long b) { long long res = a - b + mod; if (res >= mod) res -= mod; return res; } long...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long add(long long a, long long b) { long long res = a + b; if (res >= mod) res -= mod; return res; } long long sub(long long a, long long b) { long long res = a - b + mod; if (res >= mod) res -= mod; return res; } long...
insert
85
85
85
87
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define repr(i, a, n) for (int i = n - 1; i >= a; i--) using namespace std; using ll = long long; using P = pair<int, int>; template <typename T> void chmin(T &a, T b) { a = min(a, b); } template <typename T> void chmax(T &a, T b) { a = max(a, b)...
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = a; i < n; i++) #define repr(i, a, n) for (int i = n - 1; i >= a; i--) using namespace std; using ll = long long; using P = pair<int, int>; template <typename T> void chmin(T &a, T b) { a = min(a, b); } template <typename T> void chmax(T &a, T b) { a = max(a, b)...
replace
26
27
26
29
0
p03161
C++
Runtime Error
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <unordered_map> #include <utility> #include <vector> #define ll long long #define MOD 100...
#include <algorithm> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iostream> #include <iterator> #include <map> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <unordered_map> #include <utility> #include <vector> #define ll long long #define MOD 100...
replace
33
34
33
36
0
p03161
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; #define rep(i, n) for (ll i = 0; i < (ll)(n); i+...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; #define rep(i, n) for (ll i = 0; i < (ll)(n); i+...
replace
46
48
46
48
0
p03161
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast; #define int long long /* short */ #define ALL(v) begin(v), end(v) /* REPmacro */ #define FOR(i, s, n) for (int i = (s); i < (n); i++) #define RFOR(i, s, n) for (int i = (s); i >= (...
#include <bits/stdc++.h> using namespace std; struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast; #define int long long /* short */ #define ALL(v) begin(v), end(v) /* REPmacro */ #define FOR(i, s, n) for (int i = (s); i < (n); i++) #define RFOR(i, s, n) for (int i = (s); i >= (...
delete
193
194
193
193
TLE
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; int h[10102]; int64_t dp[10102]; cin >> N >> K; for (int i = 0; i < N; ++i) { cin >> h[i]; dp[i] = 100000 * 10001; } dp[0] = 0; for (int i = 0; i < N - 1; ++i) { for (int j = 1; j < K + 1; ++j) { dp[i + j] = min(dp[i...
#include <bits/stdc++.h> using namespace std; int main() { int N, K; int h[100102]; int64_t dp[100102]; cin >> N >> K; for (int i = 0; i < N; ++i) { cin >> h[i]; dp[i] = 100000 * 10001; } dp[0] = 0; for (int i = 0; i < N - 1; ++i) { for (int j = 1; j < K + 1; ++j) { dp[i + j] = min(dp...
replace
5
7
5
7
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(n, i) for (ll i = 0; i < n; ++i) const ll INF = 1e18; void solve(void) { ll n, k; cin >> n >> k; vector<ll> h(n, 0); rep(n, i) cin >> h[i]; vector<ll> dp(n + 1, INF); dp[0] = 0; for (ll i = 1; i < n; ++i) { for (ll j = 1...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(n, i) for (ll i = 0; i < n; ++i) const ll INF = 1e18; void solve(void) { ll n, k; cin >> n >> k; vector<ll> h(n, 0); rep(n, i) cin >> h[i]; vector<ll> dp(n + 1, INF); dp[0] = 0; for (ll i = 1; i < n; ++i) { for (ll j = 1...
replace
16
17
16
18
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; 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 ll IMF = 1LL << ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; 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 ll IMF = 1LL << ...
replace
34
35
34
35
0
p03161
C++
Runtime Error
#include <cmath> #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int *h = new int[n]; for (int i = 0; i < n; i++) cin >> h[i]; int *dp = new int[n]; // dp[i]はi番目の足場までの最小コスト dp[0] = 0; for (int i = 0; i < n - 1; i++) { dp[i + 1] = dp[i] + abs(h[i] - h[i + 1]); ...
#include <cmath> #include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; int *h = new int[n]; for (int i = 0; i < n; i++) cin >> h[i]; int *dp = new int[n]; // dp[i]はi番目の足場までの最小コスト dp[0] = 0; for (int i = 0; i < n - 1; i++) { dp[i + 1] = dp[i] + abs(h[i] - h[i + 1]); ...
replace
17
18
17
18
0
p03161
C++
Runtime Error
/*input 10 4 40 10 20 70 80 10 20 70 80 60 */ // author - Madhav Thakker #include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("O3") #pragma GCC optimize("O2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm...
/*input 10 4 40 10 20 70 80 10 20 70 80 60 */ // author - Madhav Thakker #include <bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("O3") #pragma GCC optimize("O2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm...
replace
86
87
86
87
0
p03161
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; typedef long long ll; const ll INF = 1LL << 60; int main() { int n, k; cin >> n >> k; int A[100000]; for (int i = 0; i < n; i++) { cin >> A[i]; } vector<ll> dp(n, INF); ...
#include <algorithm> #include <cmath> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; typedef long long ll; const ll INF = 1LL << 60; int main() { int n, k; cin >> n >> k; int A[100000]; for (int i = 0; i < n; i++) { cin >> A[i]; } vector<ll> dp(n, INF); ...
replace
24
25
24
27
0
p03161
C++
Runtime Error
/* The Island Was Silent before. ..... And One day again it became Silent. */ #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define modd(a, b) ((a + 2 * b) % b) #define debug(a) cout << #a << ": " << (a) << "\n" #define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.ti...
/* The Island Was Silent before. ..... And One day again it became Silent. */ #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ll long long #define modd(a, b) ((a + 2 * b) % b) #define debug(a) cout << #a << ": " << (a) << "\n" #define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.ti...
replace
35
39
35
41
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define itn int #define REP(i, n) for (int i = 0; i < n; i++) #define IREP(i, n) for (int i = n - 1; i >= 0; i--) #define REPEACH(i, k) for (auto &i : k) #define all(a) a.begin(), a.end() #define MOD 1000000007 using namespace std; typedef long long ll; const ll INF = 1LL << 60; signed main()...
#include <bits/stdc++.h> #define itn int #define REP(i, n) for (int i = 0; i < n; i++) #define IREP(i, n) for (int i = n - 1; i >= 0; i--) #define REPEACH(i, k) for (auto &i : k) #define all(a) a.begin(), a.end() #define MOD 1000000007 using namespace std; typedef long long ll; const ll INF = 1LL << 60; signed main()...
replace
20
21
20
21
0
p03161
C++
Runtime Error
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> #define MOD (1000000007) using namespace std; typedef long long ll; typedef pair<ll, ll> tup; const int MAX = 510000; long long fac[MAX], finv[MAX], inv[M...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> #define MOD (1000000007) using namespace std; typedef long long ll; typedef pair<ll, ll> tup; const int MAX = 510000; long long fac[MAX], finv[MAX], inv[M...
replace
91
92
91
92
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, k; cin >> N >> k; int h[N]; // INPUT ARRAY int ans[N]; // OUTPUT ARRAY for (int i = 0; i < N; i++) { cin >> h[i]; ans[i] = INT_MAX; } ans[0] = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N, j - i <= k; j++) ...
#include <bits/stdc++.h> using namespace std; int main() { int N, k; cin >> N >> k; int h[N]; // INPUT ARRAY int ans[N]; // OUTPUT ARRAY for (int i = 0; i < N; i++) { cin >> h[i]; ans[i] = INT_MAX; } ans[0] = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N && j - i <= k; j++) ...
replace
14
15
14
15
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long int nature(ll a) { // 絶対値を返す if (a >= 0) { return (a); } else { return (-1 * a); } } int main() { ll N, K, h[N], dp[N], ans; cin >> N >> K; // 足場の個数N//何個先まで飛べるかK for (ll i = 0; i < N; i++) { // 各足場の高さ cin >> h[i]; ...
#include <bits/stdc++.h> using namespace std; #define ll long long int nature(ll a) { // 絶対値を返す if (a >= 0) { return (a); } else { return (-1 * a); } } int main() { ll N, K, h[100010], dp[100010], ans; cin >> N >> K; // 足場の個数N//何個先まで飛べるかK for (ll i = 0; i < N; i++) { // 各足場の高さ cin ...
replace
11
12
11
12
-11
p03161
C++
Runtime Error
// thuanqvbn03 #include <bits/stdc++.h> using namespace std; const int MaxN = 100005; const int oo = 1e9; int n, k; int h[MaxN], dp[MaxN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> h[i]; dp[i] = oo; } dp[1] = 0;...
// thuanqvbn03 #include <bits/stdc++.h> using namespace std; const int MaxN = 100005; const int oo = 1e9; int n, k; int h[MaxN], dp[MaxN]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> h[i]; dp[i] = oo; } dp[1] = 0;...
replace
22
23
22
23
-11
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define maxx 100010 #define mp make_pair typedef pair<int, int> ii; int dp[maxx]; vector<int> peso; int x, k; int main() { cin >> x >> k; int n; for (int i = 0; i < x; i++) { cin >> n; peso.push_back(n); dp[i] = 1e9; } dp[0] = 0; dp[1] = dp[0] + ab...
#include <bits/stdc++.h> using namespace std; #define maxx 100010 #define mp make_pair typedef pair<int, int> ii; int dp[maxx]; vector<int> peso; int x, k; int main() { cin >> x >> k; int n; for (int i = 0; i < x; i++) { cin >> n; peso.push_back(n); dp[i] = 1e9; } dp[0] = 0; dp[1] = dp[0] + ab...
replace
20
23
20
23
0
p03161
C++
Runtime Error
#include <climits> #include <iostream> #include <vector> using namespace std; int main() { int n, k; cin >> n; cin >> k; vector<int> v(n); vector<int> dp(n, INT_MAX); for (int i = 0; i < n; i++) { cin >> v[i]; } dp[0] = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j <= k + i && j...
#include <climits> #include <iostream> #include <vector> using namespace std; int main() { int n, k; cin >> n; cin >> k; vector<int> v(n); vector<int> dp(n, INT_MAX); for (int i = 0; i < n; i++) { cin >> v[i]; } dp[0] = 0; for (int i = 1; i < n; i++) { for (int j = 1; j <= k && i - j >= ...
replace
20
23
20
23
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); ...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); ...
replace
25
26
25
26
0
p03161
C++
Runtime Error
// A-Frog2.cpp #include <bits/stdc++.h> #define ll long long int using namespace std; int main() { // freopen("input.txt","r",stdin); ll n, k; cin >> n >> k; ll *arr = new ll[n]; for (ll i = 0; i < n; i++) cin >> arr[i]; ll *dp = new ll[n + 1]{}; dp[0] = 0; dp[1] = abs(arr[1] - arr[0]); for (ll i...
// A-Frog2.cpp #include <bits/stdc++.h> #define ll long long int using namespace std; int main() { // freopen("input.txt","r",stdin); ll n, k; cin >> n >> k; ll *arr = new ll[n]; for (ll i = 0; i < n; i++) cin >> arr[i]; ll *dp = new ll[n + 1]{}; dp[0] = 0; dp[1] = abs(arr[1] - arr[0]); for (ll i...
replace
18
19
18
20
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define be begin #define en end #define pb push_back #define eb emplace_back #define mp make_pair #define ALL(a) (a).be(), (a).en() using LL = long long; template <typename T> using V = vector<T>; using Vi = V<int>; using Vll = V<LL>; u...
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define be begin #define en end #define pb push_back #define eb emplace_back #define mp make_pair #define ALL(a) (a).be(), (a).en() using LL = long long; template <typename T> using V = vector<T>; using Vi = V<int>; using Vll = V<LL>; u...
replace
56
57
56
57
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; #define fastio() \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; #define fastio() \ ios_base::sync_with_stdio(0); \ cin.tie(0); ...
replace
38
39
38
39
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int mod(int a) { if (a > 0) { return (a); } return (-1 * a); } int min(int a, int b) { if (a > b) { // cout<<b<<"\t" ; return (b); } // cout<<a<<"\t" ; return (a); } int main() { int a, b, c, i, j, n, k; cin >> n >> k; vector<int> v, cost; ...
#include <bits/stdc++.h> using namespace std; int mod(int a) { if (a > 0) { return (a); } return (-1 * a); } int min(int a, int b) { if (a > b) { // cout<<b<<"\t" ; return (b); } // cout<<a<<"\t" ; return (a); } int main() { int a, b, c, i, j, n, k; cin >> n >> k; vector<int> v, cost; ...
insert
31
31
31
34
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define fu(a, b) for (int i = a; i < b; i++) #define fv(a, b) for (int j = a; j < b; j++) using namespace std; int mini(int x, int y) { return x > y ? y : x; } int main() { int dp[100001]; fu(0, 100001) dp[i] = INT_MAX; dp[0] = dp[1] = 0; int n, k; cin >> n >> k; int a[n + 1]; f...
#include <bits/stdc++.h> #define fu(a, b) for (int i = a; i < b; i++) #define fv(a, b) for (int j = a; j < b; j++) using namespace std; int mini(int x, int y) { return x > y ? y : x; } int main() { int dp[100001]; fu(0, 100001) dp[i] = INT_MAX; dp[0] = dp[1] = 0; int n, k; cin >> n >> k; int a[n + 1]; f...
replace
17
21
17
20
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() typedef long long ll; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, num, n) for (ll i = num, i##_len = (n); i < i##_len; ++i) #define repprev(i, a, b) for (ll i = b - 1; i >= a; i--) #define reprev(i, n) repprev(i, 0, n) u...
#include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() typedef long long ll; #define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define REP(i, num, n) for (ll i = num, i##_len = (n); i < i##_len; ++i) #define repprev(i, a, b) for (ll i = b - 1; i >= a; i--) #define reprev(i, n) repprev(i, 0, n) u...
replace
315
316
315
320
0
p03161
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; #define rep(i, n) for (ll i = 0; i < (ll)(n); i+...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; #define rep(i, n) for (ll i = 0; i < (ll)(n); i+...
replace
52
53
52
54
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define lp(i, n) for (int i = 0; i < n; i++) #define all(x) (x).begin(), (x).end() #define pb push_back #define MP make_pair #define SZ(v) ((int)((v).size())) typedef long long ll; const ll MOD = 1e9 + 7; const int OO = (int)1e9; const int N = (int)1e5 + 5; const int K =...
#include <bits/stdc++.h> using namespace std; #define lp(i, n) for (int i = 0; i < n; i++) #define all(x) (x).begin(), (x).end() #define pb push_back #define MP make_pair #define SZ(v) ((int)((v).size())) typedef long long ll; const ll MOD = 1e9 + 7; const int OO = (int)1e9; const int N = (int)1e5 + 5; const int K =...
replace
59
60
59
60
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define fastIO \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define File ...
#include <bits/stdc++.h> using namespace std; #define fastIO \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0) #define File ...
replace
10
12
10
12
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define int long long int #define frwd(i, a, b, j) for (int i = a; i < b; i += j) #define rev(i, a, b, j) for (int i = a; i >= b; i -= j) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define tr(container, it) \ for...
#include <bits/stdc++.h> #define int long long int #define frwd(i, a, b, j) for (int i = a; i < b; i += j) #define rev(i, a, b, j) for (int i = a; i >= b; i -= j) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define tr(container, it) \ for...
replace
36
37
36
38
0
p03161
C++
Runtime Error
#pragma GCC Optimize("Ofast") #pragma GCC Optimize "trapv" #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define TC \ int t; ...
#pragma GCC Optimize("Ofast") #pragma GCC Optimize "trapv" #define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; #define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); #define TC \ int t; ...
replace
62
63
62
63
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define inf 0x7fffffff #define ll long long #define REP(i, a, b) for (int i = a; i <= b; i++) using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // Code Starts... ll n, k; cin >> n >> k; vector<ll> v(n); for (int i = 0; i < n; i++) cin >> v[i];...
#include <bits/stdc++.h> #define inf 0x7fffffff #define ll long long #define REP(i, a, b) for (int i = a; i <= b; i++) using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // Code Starts... ll n, k; cin >> n >> k; vector<ll> v(n); for (int i = 0; i < n; i++) cin >> v[i];...
replace
19
20
19
21
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:2000000") #pragma comment(linker, "/HEAP:2000000") #define ll long long #define ld long double #define ull unsigned long long #define pb push_back #define f(n) for (ll i = 0; i < n; i++) #define fn(a, n) for (ll a = 0; a < n; a++) #define flr(a, l, r) for (ll a...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:2000000") #pragma comment(linker, "/HEAP:2000000") #define ll long long #define ld long double #define ull unsigned long long #define pb push_back #define f(n) for (ll i = 0; i < n; i++) #define fn(a, n) for (ll a = 0; a < n; a++) #define flr(a, l, r) for (ll a...
delete
154
160
154
154
-6
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline...
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline...
replace
53
54
53
55
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { cin.tie(0), cout.tie(0), ios::sync_with_stdio(0); int n, k, temp; cin >> n >> k; vector<int> vec(n + 1); for (int i = 1; i <= n; i++) cin >> vec[i]; vector<int> dp(n + 3, 1e12); dp[1] = 0; dp[2] = abs(vec[2] - ve...
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { cin.tie(0), cout.tie(0), ios::sync_with_stdio(0); int n, k, temp; cin >> n >> k; vector<int> vec(n + 1); for (int i = 1; i <= n; i++) cin >> vec[i]; vector<int> dp(n + 3, 1e12); dp[1] = 0; dp[2] = abs(vec[2] - ve...
replace
18
19
18
19
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long #define db double #define pb push_back #define rep(i, a, b) for (ll i = a; i <= b; i++) #define all(a) a.begin(), a.end() using namespace std; ll mod = 1e9 + 7; const ll M = 500006; ll f[M], inv[M]; ll expo(ll base, ll exponent) { ll ans = 1; while (exponent != 0) { ...
#include <bits/stdc++.h> #define ll long long #define db double #define pb push_back #define rep(i, a, b) for (ll i = a; i <= b; i++) #define all(a) a.begin(), a.end() using namespace std; ll mod = 1e9 + 7; const ll M = 500006; ll f[M], inv[M]; ll expo(ll base, ll exponent) { ll ans = 1; while (exponent != 0) { ...
insert
101
101
101
103
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int a[n]; long long int dp[n]; for (int i = 0; i < n; i++) { cin >> a[i]; dp[i] = 1000000000000000; } dp[0] = 0; dp[1] = abs(a[1] - a[0]); for (int i = 2; i < k; i++) { for (int j = 0; j < i; j++) { ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int a[400000]; long long int dp[n]; for (int i = 0; i < n; i++) { cin >> a[i]; dp[i] = 1000000000000000; } dp[0] = 0; dp[1] = abs(a[1] - a[0]); for (int i = 2; i < k; i++) { for (int j = 0; j < i; j++) { ...
replace
5
6
5
6
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; int dp[n]; dp[0] = 0; dp[1] = abs(v[1] - v[0]); for (int i = 2; i < n; i++) { dp[i] = dp[i - 1] + abs(v[i] - v[i - 1]); for (int j = 2; j <= k; j++)...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; int dp[n]; dp[0] = 0; dp[1] = abs(v[1] - v[0]); for (int i = 2; i < n; i++) { dp[i] = dp[i - 1] + abs(v[i] - v[i - 1]); for (int j = 2; j <= k && i ...
replace
14
15
14
15
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define FASTIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define ll long ...
#include <bits/stdc++.h> using namespace std; #define FASTIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define ll long ...
replace
39
40
39
43
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, k; cin >> n >> k; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int dp[n]; dp[0] = 0; for (int i = 1; i < k; i++) { int m = INT_MAX; for (int j = 0; j <...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, k; cin >> n >> k; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int dp[n]; dp[0] = 0; for (int i = 1; i < k && i < n; i++) { int m = INT_MAX; for (int j...
replace
13
14
13
14
0
p03161
C++
Runtime Error
// Frog-1 #include <bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back #define N (ll)(1e7 + 5) #define mod (ll)(1e9 + 7) using namespace std; int main() { ll n, k; cin >> n >> k; vector<ll> dp(n), v(n); for (auto &x : v) cin >> x; dp[1] = abs(v[1] - v[0]); for...
// Frog-1 #include <bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back #define N (ll)(1e7 + 5) #define mod (ll)(1e9 + 7) using namespace std; int main() { ll n, k; cin >> n >> k; vector<ll> dp(n), v(n); for (auto &x : v) cin >> x; dp[1] = abs(v[1] - v[0]); for...
replace
21
22
21
22
0
p03161
C++
Runtime Error
/* ########################### # Author : Pranay Garg # # College : SGSITS # ########################### */ #include <bits/stdc++.h> #define ll long long int #define ironman \ ios_base::sync_with_stdio(false); ...
/* ########################### # Author : Pranay Garg # # College : SGSITS # ########################### */ #include <bits/stdc++.h> #define ll long long int #define ironman \ ios_base::sync_with_stdio(false); ...
replace
56
57
56
57
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define deb(x) cout << #x << "=" << x << endl; #define fo(i, n) for (ll i = 0; i < n; i++) #define fo1(i, n) \ for (ll i = 1; i <= n; i++) \ i #define sn(x) cin >> x; #define pn(x)...
#include <bits/stdc++.h> #define deb(x) cout << #x << "=" << x << endl; #define fo(i, n) for (ll i = 0; i < n; i++) #define fo1(i, n) \ for (ll i = 1; i <= n; i++) \ i #define sn(x) cin >> x; #define pn(x)...
replace
34
35
34
36
-6
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, x, y) for (int i = x; i < y; i++) #define rel(i, x, y) for (int i = x - 1; i >= y; i--) #define all(x) x.begin(), x.end() ll inf = 1e18 + 7; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, k; cin >> n >> k; l...
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, x, y) for (int i = x; i < y; i++) #define rel(i, x, y) for (int i = x - 1; i >= y; i--) #define all(x) x.begin(), x.end() ll inf = 1e18 + 7; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, k; cin >> n >> k; l...
insert
20
20
20
22
0
p03161
C++
Time Limit Exceeded
// dp_b.cc #include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 5; int main() { int n, k; scanf("%d%d", &n, &k); vector<int> h(n); for (int &x : h) scanf("%d", &x); vector<int> dp(n, INF); dp[0] = 0; for (int i = 0; i < n; i++) { for (int j = 1; j <= i + k; j++) { if (j <...
// dp_b.cc #include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 5; int main() { int n, k; scanf("%d%d", &n, &k); vector<int> h(n); for (int &x : h) scanf("%d", &x); vector<int> dp(n, INF); dp[0] = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j <= i + k; j++) { if ...
replace
18
19
18
19
TLE
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, *p, *dp; cin >> n; cin >> k; p = new long long[n]; for (long long y = 0; y < n; y++) { cin >> p[y]; } dp = new long long[n]; dp[0] = 0; dp[1] = abs(p[1] - p[0]); for (long long i = 2; i < n; i++) { long long minimo =...
#include <bits/stdc++.h> using namespace std; int main() { long long n, k, *p, *dp; cin >> n; cin >> k; p = new long long[n]; for (long long y = 0; y < n; y++) { cin >> p[y]; } dp = new long long[n]; dp[0] = 0; dp[1] = abs(p[1] - p[0]); for (long long i = 2; i < n; i++) { long long minimo =...
replace
16
17
16
17
0
p03161
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <time.h> #include <vector> using namespace std; #define rep(i, a) for (int i = 0; i < a; i++) #define pd(a, n) ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <time.h> #include <vector> using namespace std; #define rep(i, a) for (int i = 0; i < a; i++) #define pd(a, n) ...
replace
29
30
29
30
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> dp(n); int pos = a[0]; dp[0] = 0; dp[1] = abs(a[0] - a[1]); for (int i = 2; i < n; i++) { dp[i] = dp[i - 1] + abs(a[i - 1] - a[i])...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> dp(n); int pos = a[0]; dp[0] = 0; dp[1] = abs(a[0] - a[1]); for (int i = 2; i < n; i++) { dp[i] = dp[i - 1] + abs(a[i - 1] - a[i])...
replace
18
20
18
20
0
p03161
C++
Runtime Error
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <utility> #include <vector> typedef long long ll; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; const...
#include <algorithm> #include <iostream> #include <map> #include <math.h> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <utility> #include <vector> typedef long long ll; const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; const...
replace
71
73
71
74
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int a[n]; int dp[n]; for (int i = 0; i < n; i++) { dp[i] = INT_MAX; } for (int i = 0; i < n; i++) { cin >> a[i]; } dp[0] = 0; for (int i = 0; i < n; i++) { for (int j = 1; j <= k; j++) { dp[i + j] ...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int a[n]; int dp[n]; for (int i = 0; i < n; i++) { dp[i] = INT_MAX; } for (int i = 0; i < n; i++) { cin >> a[i]; } dp[0] = 0; for (int i = 0; i < n; i++) { for (int j = 1; j <= k; j++) { if (i + j ...
replace
17
18
17
19
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define for0(i, n) for (long long i = 0; i < n; i++) #define for1(i, n) for (long long i = 1; i <= n; i++) #define forc(i, l, r) for (long long i = l; i <= r; ++i) #define forr0(i, n) for (long long i = n - 1; i >= 0; i--) #define forr1(i, n) for (long long i = n; i >= 1; i--) #define pb push...
#include <bits/stdc++.h> #define for0(i, n) for (long long i = 0; i < n; i++) #define for1(i, n) for (long long i = 1; i <= n; i++) #define forc(i, l, r) for (long long i = l; i <= r; ++i) #define forr0(i, n) for (long long i = n - 1; i >= 0; i--) #define forr1(i, n) for (long long i = n; i >= 1; i--) #define pb push...
replace
27
28
27
28
0
p03161
C++
Runtime Error
// INCLUDE //------------------------------------------ #include <algorithm> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <math.h> #include <string> #include <vector> // DEFINE //------------------------------------------ #define ll long long #define ALLv(a) (a).begin(), (a)....
// INCLUDE //------------------------------------------ #include <algorithm> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <math.h> #include <string> #include <vector> // DEFINE //------------------------------------------ #define ll long long #define ALLv(a) (a).begin(), (a)....
replace
40
41
40
41
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define ios \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define ll long long #define ld long ...
#include <bits/stdc++.h> #define ios \ ios_base::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define ll long long #define ld long ...
replace
105
106
105
107
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 5; int main() { int n, k; cin >> n >> k; vector<int> stone(n); for (int i = 0; i < n; i++) cin >> stone[i]; vector<int> dp(n, INF); dp[0] = 0; for (int i = 0; i < n; i++) for (int j = i + 1; j <= i + k; j++) dp[j] = min(d...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 5; int main() { int n, k; cin >> n >> k; vector<int> stone(n); for (int i = 0; i < n; i++) cin >> stone[i]; vector<int> dp(n, INF); dp[0] = 0; for (int i = 0; i < n; i++) for (int j = i + 1; j <= i + k; j++) if (j < n) ...
replace
16
17
16
18
-6
Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)
p03161
C++
Runtime Error
#include <bits/stdc++.h> #include <iostream> using namespace std; int mod(int x) { if (x > 0) return x; return -x; } int main() { int n, k; cin >> n >> k; int h[n], result[n]; for (int i = 0; i < n; i++) cin >> h[i]; for (int i = 0; i <= k; i++) result[i] = mod(h[i] - h[0]); for (int i = k +...
#include <bits/stdc++.h> #include <iostream> using namespace std; int mod(int x) { if (x > 0) return x; return -x; } int main() { int n, k; cin >> n >> k; int h[n], result[n]; for (int i = 0; i < n; i++) cin >> h[i]; for (int i = 0; i <= k && i < n; i++) result[i] = mod(h[i] - h[0]); for (in...
replace
14
15
14
15
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long int i = 0; i < n; ++i) typedef long long int ll; int main() { int n, k; cin >> n >> k; vector<int> h(n); rep(i, n) cin >> h[i]; vector<int> c(n, 1e+9); c[0] = 0; c[1] = abs(h[0] - h[1]); for (int i = 2; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (long long int i = 0; i < n; ++i) typedef long long int ll; int main() { int n, k; cin >> n >> k; vector<int> h(n); rep(i, n) cin >> h[i]; vector<int> c(n, 1e+9); c[0] = 0; c[1] = abs(h[0] - h[1]); for (int i = 2; i < n; i++) { ...
replace
20
21
20
21
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define int long long #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout....
#include <bits/stdc++.h> using namespace std; #define int long long #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout....
replace
34
39
34
40
-6
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
p03161
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; void solve() { int n, k; cin >> n; cin >> k; const int INF = 1e9 + 5; vector<int> dp(n + 1, INF); int H[n + 1]; for (int i = 1; i < n + 1; i++) { cin >> H[i]; } dp[1] = 0; dp[2] = abs(H[1] - H[2]); for (int i = 1; i < n + 1; i++) { for (int j...
#include <bits/stdc++.h> using namespace std; void solve() { int n, k; cin >> n; cin >> k; const int INF = 1e9 + 5; vector<int> dp(n + 1, INF); int H[n + 1]; for (int i = 1; i < n + 1; i++) { cin >> H[i]; } dp[1] = 0; dp[2] = abs(H[1] - H[2]); for (int i = 1; i < n + 1; i++) { for (int j...
replace
17
18
17
18
TLE
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } int dp[n]; memset(dp, -1, sizeof(dp)); dp[0] = 0; for (int i = 1; i <= k; i++) { dp[i] = abs(arr[0] - arr[i]); } for (int i = k + 1; i < n; i++...
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } if (k >= n - 1) { cout << abs(arr[0] - arr[n - 1]) << "\n"; return 0; } int dp[n]; memset(dp, -1, sizeof(dp)); dp[0] = 0; for (int i = 1; ...
insert
11
11
11
17
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define For(i, n) for (ll i = 1; i <= n; ++i) int main() { ll n, k; cin >> n >> k; ll h[n + 1], dp[n + 1]; For(i, n) { cin >> h[i]; dp[i] = 0; } dp[2] = abs(h[2] - h[1]); For(i, k - 2) { dp[i + 2] = dp[1] + abs(h[1] - h[i + 2...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define For(i, n) for (ll i = 1; i <= n; ++i) int main() { ll n, k; cin >> n >> k; ll h[n + 1], dp[n + 1]; For(i, n) { cin >> h[i]; dp[i] = 0; } dp[2] = abs(h[2] - h[1]); if (k <= n) { For(i, k - 2) { dp[i + 2] = dp[1] ...
replace
14
24
14
32
0
p03161
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { int n, k; cin >> n >> k; int h[n]; for (int i = 0; i < n; i++) cin >> h[i]; ll ans = 0; int dp[n]; // cost dp[0] = 0; dp[1] = abs(h[1] - h[0]); for (int i = 2; i < n; i++) dp[i] = 1e9; for (int i = 2; i < n; i++)...
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { int n, k; cin >> n >> k; int h[n]; for (int i = 0; i < n; i++) cin >> h[i]; ll ans = 0; int dp[n]; // cost dp[0] = 0; dp[1] = abs(h[1] - h[0]); for (int i = 2; i < n; i++) dp[i] = 1e9; for (int i = 2; i < n; i++)...
replace
20
21
20
22
TLE
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define fastio() \ ios_base::sync_with_stdio(0); \ cin.tie(0)...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<int, int> pii; #define fastio() \ ios_base::sync_with_stdio(0); \ cin.tie(0)...
replace
31
32
31
32
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define sd(x) scanf("%d", &x) #define slld(x) scanf("%lld", &x) #define all(x) x.begin(), x.end() #define For(i, st, en) for (int i = st; i < en; i++) #define tr(x) for (auto it = x.begin(); it != x.end(); it++) #define fast ...
#include <bits/stdc++.h> using namespace std; #define sd(x) scanf("%d", &x) #define slld(x) scanf("%lld", &x) #define all(x) x.begin(), x.end() #define For(i, st, en) for (int i = st; i < en; i++) #define tr(x) for (auto it = x.begin(); it != x.end(); it++) #define fast ...
replace
37
38
37
42
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; using ll = long long; using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using pll = pair<ll, ll>; using tll = tuple<ll, ll>; usin...
#include <bits/stdc++.h> using namespace std; using ll = long long; using vb = vector<bool>; using vvb = vector<vb>; using vd = vector<double>; using vvd = vector<vd>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using pll = pair<ll, ll>; using tll = tuple<ll, ll>; usin...
replace
108
110
108
110
0
p03161
C++
Runtime Error
/* Author: Sanskar Agarwal Nick: sanskarag Birla Institute Of Technology, Mesra */ #include <bits/stdc++.h> using namespace std; #define ll long long int #define endl "\n" #define fast \ ios::sync_with_stdio(0); ...
/* Author: Sanskar Agarwal Nick: sanskarag Birla Institute Of Technology, Mesra */ #include <bits/stdc++.h> using namespace std; #define ll long long int #define endl "\n" #define fast \ ios::sync_with_stdio(0); ...
replace
46
50
46
50
-11
p03161
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <vector> using namespace std; #include <bits/stdc++.h> #define ll long long #define ld long double #define el '\n' #define rep(i, a, b) for (ll i = (a); i < (b); i++) #define repd(i, a, b) for (ll i = (b)-1; i >= (a); i--) #define larg...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> #include <vector> using namespace std; #include <bits/stdc++.h> #define ll long long #define ld long double #define el '\n' #define rep(i, a, b) for (ll i = (a); i < (b); i++) #define repd(i, a, b) for (ll i = (b)-1; i >= (a); i--) #define larg...
replace
39
43
39
40
-11
p03161
C++
Runtime Error
#include <cstdlib> #include <iostream> #include <vector> using namespace std; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const long ...
#include <cstdlib> #include <iostream> #include <vector> using namespace std; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const long ...
replace
23
25
23
25
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define inf 1e18 #define ll long long int using namespace std; int main(void) { int i, j, n, k; cin >> n >> k; ll a[n]; for (i = 0; i < n; i++) cin >> a[i]; ll dp[n + 1]; for (i = 0; i <= n; i++) dp[i] = inf; dp[1] = 0; dp[2] = abs(a[1] - a[0]); for (i = 3; i <= k; i+...
#include <bits/stdc++.h> #define inf 1e18 #define ll long long int using namespace std; int main(void) { int i, j, n, k; cin >> n >> k; ll a[n]; for (i = 0; i < n; i++) cin >> a[i]; ll dp[n + 1]; for (i = 0; i <= n; i++) dp[i] = inf; dp[1] = 0; dp[2] = abs(a[1] - a[0]); for (i = 3; i <= min(n...
replace
16
17
16
17
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define filename "frog" #define int long long #define oo 1e9 #define N 25 using namespace std; int n, k; int f[N], a[N]; void open() { // freopen(filename".inp","r",stdin) ; // freopen(filename".out","w",stdout) ; ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } void readin(...
#include <bits/stdc++.h> #define filename "frog" #define int long long #define oo 1e9 #define N 200005 using namespace std; int n, k; int f[N], a[N]; void open() { // freopen(filename".inp","r",stdin) ; // freopen(filename".out","w",stdout) ; ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } void rea...
replace
4
5
4
5
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long int #define mod 1000000007 using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; int h[n]; for (int i = 0; i < n; i++) { cin >> h[i]; } int dp[n]; for (int i = 0; i <= k; i++) { if (!i) { ...
#include <bits/stdc++.h> #define ll long long int #define mod 1000000007 using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, k; cin >> n >> k; int h[n]; for (int i = 0; i < n; i++) { cin >> h[i]; } if (n <= k) { int ans = abs(h[0] - h[n - 1]); cout...
insert
17
17
17
23
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<long long> h(N); for (int i = 0; i < N; i++) { cin >> h[i]; } const long long INF = 1e16; long long dp[N]; fill(dp, dp + N, INF); dp[0] = 0; for (int i = 1; i < N; i++) { for (int j = i - K; j < i; ...
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<long long> h(N); for (int i = 0; i < N; i++) { cin >> h[i]; } const long long INF = 1e16; long long dp[N]; fill(dp, dp + N, INF); dp[0] = 0; for (int i = 1; i < N; i++) { for (int j = i - K; j < i; ...
replace
18
19
18
21
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } vector<int> dp(n); dp[0] = 0; dp[1] = abs(v[0] - v[1]); int x; for (int i = 2; i < n; i++) { x = 10...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } vector<int> dp(n); dp[0] = 0; dp[1] = abs(v[0] - v[1]); int x; for (int i = 2; i < n; i++) { x = IN...
replace
17
19
17
19
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define MAXN 100005 #define ll long long using namespace std; ll dp[MAXN]; int n, k; vector<ll> v; ll solve(int i) { if (i < 0) return 0; if (dp[i] >= 0) { return dp[i]; } ll res1 = -1; for (int j = 1; j <= k; ++j) if (res1 != -1) res1 = min(res1, abs(v[i] - v[i -...
#include <bits/stdc++.h> #define MAXN 100005 #define ll long long using namespace std; ll dp[MAXN]; int n, k; vector<ll> v; ll solve(int i) { if (i < 0) return 0; if (dp[i] >= 0) { return dp[i]; } ll res1 = -1; for (int j = 1; j <= min(k, i); ++j) if (res1 != -1) res1 = min(res1, abs(v[i]...
replace
17
18
17
18
0
p03161
C++
Time Limit Exceeded
#include <bits/stdc++.h> typedef long long ll; using namespace std; ll n, h, ans[100005], arr[100005], sto[100005]; ll solve(int ind) { if (ind >= n) return 2e9; if (ind == n - 1) return 0; if (~sto[ind]) return sto[ind]; ll ans = 2e9; for (int i = 1; i <= min(n - ind, h); i++) ans = min(ans, ...
#include <bits/stdc++.h> typedef long long ll; using namespace std; ll n, h, ans[100005], arr[100005], sto[100005]; ll solve(int ind) { if (ind >= n) return 2e9; if (ind == n - 1) return 0; if (~sto[ind]) return sto[ind]; ll ans = 2e9; for (int i = 1; i <= min(n - ind, h); i++) ans = min(ans, ...
insert
14
14
14
15
TLE
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define fastio \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define range(i, l, h) for (int i = l...
#include <bits/stdc++.h> #define fastio \ ios::sync_with_stdio(false); \ cin.tie(0); \ cout.tie(0); #define range(i, l, h) for (int i = l...
delete
22
26
22
22
-11
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define pb push_back #define un unordered_map #define us unordered_set #define ll long long #define l long using namespace std; const int mod = 1e9 + 7; const int inf = 1e9 + 3; int main() { l n, k; cin >> n >> k; vector<l> v(n); for (l i = 0; i < n; i++) { cin >> v[i]; } l dp[...
#include <bits/stdc++.h> #define pb push_back #define un unordered_map #define us unordered_set #define ll long long #define l long using namespace std; const int mod = 1e9 + 7; const int inf = 1e9 + 3; int main() { l n, k; cin >> n >> k; vector<l> v(n); for (l i = 0; i < n; i++) { cin >> v[i]; } l dp[...
insert
23
23
23
25
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> #define ll long long int #define ld long double #define pb push_back #define mp make_pair #define mod 998244353 #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); ...
#include <bits/stdc++.h> #define ll long long int #define ld long double #define pb push_back #define mp make_pair #define mod 998244353 #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); ...
replace
31
32
31
32
-11
p03161
C++
Runtime Error
#include <iostream> #include <limits.h> using namespace std; int dp[100004]; int k; int mincost(int n, int height[]) { if (n == 1 || n == 0) return 0; if (dp[n] != -1) return dp[n]; int cost1 = INT_MAX; for (int i = 1; i <= k; i++) { if (n - i - 1 >= 0 && n - i >= 0) cost1 = min(cost1, abs(hei...
#include <iostream> #include <limits.h> using namespace std; int dp[100004]; int k; int mincost(int n, int height[]) { if (n == 1 || n == 0) return 0; if (dp[n] != -1) return dp[n]; int cost1 = INT_MAX; for (int i = 1; i <= k; i++) { if (n - i - 1 >= 0 && n - i >= 0) cost1 = min(cost1, abs(hei...
replace
22
23
22
23
0
p03161
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define pb push_back #define INF 0x3f3f3f3f #define LINF 0x3f3f3f3f3f3f3f3f #define ms memset // #define MAXN 10005 // #define MAXM 100005 #define pi 3.14159265359 typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pair<int, int>> vpii; typedef long long l...
#include <bits/stdc++.h> using namespace std; #define pb push_back #define INF 0x3f3f3f3f #define LINF 0x3f3f3f3f3f3f3f3f #define ms memset // #define MAXN 10005 // #define MAXM 100005 #define pi 3.14159265359 typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pair<int, int>> vpii; typedef long long l...
replace
39
40
39
40
TLE
p03161
C++
Runtime Error
/* Jay Solanki */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> typedef long long int ll; #define pii pair<ll, ll> #define pb push_back #define pf push_front #define F first #define S second #define mp make_pair #define For(i, a, b) for (ll i = a; i < b; i++) #define FAST ...
/* Jay Solanki */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> typedef long long int ll; #define pii pair<ll, ll> #define pb push_back #define pf push_front #define F first #define S second #define mp make_pair #define For(i, a, b) for (ll i = a; i < b; i++) #define FAST ...
replace
72
73
72
73
0
p03161
C++
Runtime Error
#include <iostream> #include <vector> #define FASTIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define INF 1e9 + 5 usi...
#include <iostream> #include <vector> #define FASTIO \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define INF 1e9 + 5 usi...
replace
45
47
45
48
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define inf (pow(10, 18)) #define ll long long int #define mod 1000000007 #define ntq(z) \ long long int z; \ cin >> z; ...
#include <bits/stdc++.h> using namespace std; #define inf (pow(10, 18)) #define ll long long int #define mod 1000000007 #define ntq(z) \ long long int z; \ cin >> z; ...
delete
152
156
152
152
-6
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
p03161
C++
Runtime Error
#include <cmath> #include <iostream> using namespace std; typedef long long ll; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } const long long LINF ...
#include <cmath> #include <iostream> using namespace std; typedef long long ll; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; } const long long LINF ...
replace
38
39
38
39
0
p03161
C++
Runtime Error
#include <cstdlib> #include <iostream> #include <vector> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INF = 1LL...
#include <cstdlib> #include <iostream> #include <vector> using namespace std; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INF = 1LL...
replace
28
30
28
30
0
p03161
C++
Runtime Error
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <limits.h> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef l...
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstring> #include <functional> #include <iostream> #include <limits.h> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef l...
replace
35
36
35
36
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define REPR(i, n) for (ll i = n; i >= 0; --i) #define FOR(i, m, n) for (ll i = m, i##_len = (n); i < i##_len; ++i) #define all(x) (x).begin(), (x).end() template <class T> inline bool c...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i) #define REPR(i, n) for (ll i = n; i >= 0; --i) #define FOR(i, m, n) for (ll i = m, i##_len = (n); i < i##_len; ++i) #define all(x) (x).begin(), (x).end() template <class T> inline bool c...
replace
48
49
48
49
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define rep(i, n) FOR(i, 0, n - 1) typedef long long ll; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> inline bool chmax(T &a, T b) { if...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define rep(i, n) FOR(i, 0, n - 1) typedef long long ll; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> inline bool chmax(T &a, T b) { if...
replace
31
37
31
34
0
p03161
C++
Runtime Error
/* Educational DP Contest 2019/1/6 * B Frog-2 * 2020.3.29 練習 * Aの変化系.ジャンプ先が最大100から選ぶことになる. */ #include <algorithm> // max #include <iostream> #include <vector> // #include<cmath> using namespace std; int abs(int x) { return (x >= 0) ? x : -x; } // 最長増加部分列(LIS) int n; // 2~10^5 int k; // 1~1...
/* Educational DP Contest 2019/1/6 * B Frog-2 * 2020.3.29 練習 * Aの変化系.ジャンプ先が最大100から選ぶことになる. */ #include <algorithm> // max #include <iostream> #include <vector> // #include<cmath> using namespace std; int abs(int x) { return (x >= 0) ? x : -x; } // 最長増加部分列(LIS) int n; // 2~10^5 int k; // 1~1...
insert
59
59
59
62
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define fo(i, n) for (int i = 0; i < n; i++) int main() { int n, k, var; cin >> n >> k; long arr[n], temp[n], mi; fo(i, n) cin >> arr[i]; fo(i, n) { var = i - 1; mi = INT_MAX; while (var >= 0 && var >= i - k) { mi = min(abs(arr[i] - arr[var]...
#include <bits/stdc++.h> using namespace std; #define fo(i, n) for (int i = 0; i < n; i++) int main() { int n, k, var; cin >> n >> k; long arr[n], temp[n], mi; fo(i, n) cin >> arr[i]; fo(i, n) { var = i - 1; mi = INT_MAX; while (var >= 0 && var >= i - k) { mi = min(abs(arr[i] - arr[var]...
replace
24
25
24
25
1
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) x.begin(), x.end() typedef long long ll; int main() { int n, k; cin >> n >> k; int h[n]; rep(i, n) cin >> h[i]; int dp[n]; rep(i, n) dp[i] = 1e9; dp[0] = 0; for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) x.begin(), x.end() typedef long long ll; int main() { int n, k; cin >> n >> k; int h[110000]; rep(i, n) cin >> h[i]; int dp[n]; rep(i, n) dp[i] = 1e9; dp[0] = 0; for (int i = 0; i < n; i++)...
replace
9
10
9
10
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n, i, k, c = 0, j; cin >> n >> k; int a[n]; long long dp[n]; for (i = 0; i < n; i++) { cin >> a[i]; } dp[0] = 0; dp[1] = abs(a[1] - a[0]); for (i = 2; i <= k; i++) { c = 0; for (j = i; j >= 1; j--) { if (j == i) { ...
#include <bits/stdc++.h> using namespace std; int main() { int n, i, k, c = 0, j; cin >> n >> k; int a[n]; long long dp[n]; for (i = 0; i < n; i++) { cin >> a[i]; } dp[0] = 0; dp[1] = abs(a[1] - a[0]); for (i = 2; i <= min(k, n - 1); i++) { c = 0; for (j = i; j >= 1; j--) { if (j == ...
replace
12
13
12
13
0
p03161
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define endl "\n...
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define endl "\n...
replace
10
15
10
16
-11