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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
p03160 | C++ | Runtime Error | /**
* Title: A - Frog 1
* Url: https://atcoder.jp/contests/dp/tasks/dp_a
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAX_N = 10000;
int main() {
int n;
cin >> n;
int h[MAX_N + 1];
int cost[MAX_N + 1];
for (int i = 0; i < n; i++)
cin >> h[i + 1];
for (int i = 1;... | /**
* Title: A - Frog 1
* Url: https://atcoder.jp/contests/dp/tasks/dp_a
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAX_N = 100000;
int main() {
int n;
cin >> n;
int h[MAX_N + 1];
int cost[MAX_N + 1];
for (int i = 0; i < n; i++)
cin >> h[i + 1];
for (int i = 1... | replace | 10 | 11 | 10 | 11 | 0 | |
p03160 | C++ | Time Limit Exceeded | #include <iostream>
#include <vector>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> H(N);
for (int i = 0; i < N; ++i) {
cin >> H[i];
}
vector<int> c(N, 0);
for (int i = 1; i < N; ++i) {
if (i = 1) {
c[i] = c[i - 1] + abs(H[i] - H[i - 1]);
} else {
c[i] =
... | #include <iostream>
#include <vector>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> H(N);
for (int i = 0; i < N; ++i) {
cin >> H[i];
}
vector<int> c(N, 0);
for (int i = 1; i < N; ++i) {
if (i == 1) {
c[i] = c[i - 1] + abs(H[i] - H[i - 1]);
} else {
c[i] =
... | replace | 12 | 13 | 12 | 13 | TLE | |
p03160 | C++ | Time Limit Exceeded | #include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
#pragma GCC oprimize("Ofast")
#define rep(i, a, b) for (__typeof(b) i = a; i < b; ++i)
typedef long long ll;
typedef vector<ll> vl;
const ll inf = 100000000000;
ll n;
ll mem[100010];
vl l;
ll dp(ll at) {
if (at > n ... | #include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
#pragma GCC oprimize("Ofast")
#define rep(i, a, b) for (__typeof(b) i = a; i < b; ++i)
typedef long long ll;
typedef vector<ll> vl;
const ll inf = 100000000000;
ll n;
ll mem[100010];
vl l;
ll dp(ll at) {
if (at > n ... | replace | 29 | 30 | 29 | 30 | TLE | |
p03160 | 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); ... | delete | 21 | 25 | 21 | 21 | 0 | |
p03160 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#define ll long long
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(0); ... | #include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#define ll long long
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(0); ... | replace | 72 | 74 | 72 | 74 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
#define INF 1000000000
#define MOD 1000000007
#define itr ::iterator it
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a),... | #include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
#define INF 1000000000
#define MOD 1000000007
#define itr ::iterator it
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) * (b)) / gcd((a),... | delete | 25 | 29 | 25 | 25 | -11 | |
p03160 | C++ | Runtime Error | //*-- ILSH --*//
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vpi vector<pii>
#define vpl vector<pll>
#de... | //*-- ILSH --*//
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector<int>
#define vll vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vpi vector<pii>
#define vpl vector<pll>
#de... | replace | 71 | 75 | 71 | 72 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag,
... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag,
... | delete | 65 | 70 | 65 | 65 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()), ((v).end())
#define rall(v) ((v).rbegin()), ((v).rend())
#define clr(v, line) memset(v, line, sizeof(v))
#define endl '\n'
#define TRACE
#ifdef TRACE
#define trace(...) __... | #include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define all(v) ((v).begin()), ((v).end())
#define rall(v) ((v).rbegin()), ((v).rend())
#define clr(v, line) memset(v, line, sizeof(v))
#define endl '\n'
#define TRACE
#ifdef TRACE
#define trace(...) __... | replace | 55 | 56 | 55 | 56 | 0 | |
p03160 | C++ | Runtime Error | /*
TASK: nocows
LANG: C++14
*/
#include "bits/stdc++.h"
typedef long long ll;
typedef long double ld;
using namespace std;
#define finish(x) return cout << x, 0;
void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(), "w", stdout); }
const string USCAO_TAG = "nocow... | /*
TASK: nocows
LANG: C++14
*/
#include "bits/stdc++.h"
typedef long long ll;
typedef long double ld;
using namespace std;
#define finish(x) return cout << x, 0;
void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(), "w", stdout); }
const string USCAO_TAG = "nocow... | replace | 26 | 28 | 26 | 28 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset((a), 0, sizeof(a))
#define set1(a) memset((a), -1, sizeof(a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl... | #include <bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset((a), 0, sizeof(a))
#define set1(a) memset((a), -1, sizeof(a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl... | insert | 47 | 47 | 47 | 48 | 0 | |
p03160 | C++ | Time Limit Exceeded | /*
TASK: nocows
LANG: C++14
*/
#include "bits/stdc++.h"
typedef long long ll;
typedef long double ld;
using namespace std;
#define finish(x) return cout << x, 0;
void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(), "w", stdout); }
const string USCAO_TAG = "nocow... | /*
TASK: nocows
LANG: C++14
*/
#include "bits/stdc++.h"
typedef long long ll;
typedef long double ld;
using namespace std;
#define finish(x) return cout << x, 0;
void setIn(string s) { freopen(s.c_str(), "r", stdin); }
void setOut(string s) { freopen(s.c_str(), "w", stdout); }
const string USCAO_TAG = "nocow... | replace | 50 | 51 | 50 | 51 | TLE | |
p03160 | C++ | Runtime Error | #include <iostream>
using namespace std;
int findMin(int h[], int n) {
int cost[n];
cost[0] = 0;
cost[1] = abs(h[0] - h[1]);
for (int i = 2; i < n; i++)
cost[i] = min(cost[i - 1] + abs(h[i] - h[i - 1]),
cost[i - 2] + abs(h[i] - h[i - 2]));
return cost[n - 1];
}
int main() {
int n;
... | #include <iostream>
using namespace std;
int findMin(int h[], int n) {
int cost[n];
cost[0] = 0;
cost[1] = abs(h[0] - h[1]);
for (int i = 2; i < n; i++)
cost[i] = min(cost[i - 1] + abs(h[i] - h[i - 1]),
cost[i - 2] + abs(h[i] - h[i - 2]));
return cost[n - 1];
}
int main() {
int n;
... | replace | 17 | 18 | 17 | 18 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, h[10000], dp[10000];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h[i];
}
dp[0] = 0;
dp[1] = abs(h[0] - h[1]);
for (int i = 2; i < n; i++) {
dp[i] =
min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, h[100000], dp[100000];
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h[i];
}
dp[0] = 0;
dp[1] = abs(h[0] - h[1]);
for (int i = 2; i < n; i++) {
dp[i] =
min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - ... | replace | 4 | 5 | 4 | 5 | 0 | |
p03160 | 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 lli long... | #include <bits/stdc++.h>
using namespace std;
#define fastio \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define lli long... | replace | 27 | 28 | 27 | 28 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const int p = 10e5 + 5;
int h[p], dp[p];
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
for (int i = 1; i <= ... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const int p = 10e5 + 5;
int h[p], dp[p];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> h[i];
dp[i] = 10e5;
}
dp[0] = 0;
dp[1] = 0;
dp[2] = abs(h[1] - h[2]);... | delete | 6 | 10 | 6 | 6 | 0 | |
p03160 | C++ | Runtime Error | #include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
ll dp[10009];
int arr[100009];
ll sum = 0;
long long Frog1(int n) {
if (n == 0)
return 0;
else if (n == 1)
return abs(arr[n] - arr[n - 1]);
if (dp[n] != -1)
return dp[n];
else {
ll x = Frog1(n -... | #include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
ll dp[100009];
int arr[100009];
ll sum = 0;
long long Frog1(int n) {
if (n == 0)
return 0;
else if (n == 1)
return abs(arr[n] - arr[n - 1]);
if (dp[n] != -1)
return dp[n];
else {
ll x = Frog1(n ... | replace | 5 | 6 | 5 | 6 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
#define l(i, a, b) for (auto i = a; i < b; i++)
#define lr(i, a, b) for (auto i = a; i >= b; i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll, ll>
#define vl vector<long long>
#define se set<long long int>
#define pi pair<long... | #include <bits/stdc++.h>
#define l(i, a, b) for (auto i = a; i < b; i++)
#define lr(i, a, b) for (auto i = a; i >= b; i--)
#define ll long long
#define lli long long int
#define ld long double
#define vec vector<int>
#define mii map<ll, ll>
#define vl vector<long long>
#define se set<long long int>
#define pi pair<long... | replace | 26 | 28 | 26 | 28 | 0 | |
p03160 | C++ | Runtime Error | // Code by : Abhishek Tiwari
// codechef.com/users/devil_within || hackerearth.com/@devil_within
#include <bits/stdc++.h>
#define fio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); ... | // Code by : Abhishek Tiwari
// codechef.com/users/devil_within || hackerearth.com/@devil_within
#include <bits/stdc++.h>
#define fio \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); ... | replace | 62 | 65 | 62 | 64 | -11 | |
p03160 | C++ | Runtime Error | #include <cstring>
#include <iostream>
using namespace std;
const int MAXN = 10010;
int h[MAXN], dp[MAXN];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> h[i];
memset(dp, 0xff, sizeof(dp));
dp[0] = 0;
for (int i = 0; i < n; i++) {
if (dp[i + 1] == -1 || dp[i + 1] > dp[i] + abs(h[i... | #include <cstring>
#include <iostream>
using namespace std;
const int MAXN = 100010;
int h[MAXN], dp[MAXN];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> h[i];
memset(dp, 0xff, sizeof(dp));
dp[0] = 0;
for (int i = 0; i < n; i++) {
if (dp[i + 1] == -1 || dp[i + 1] > dp[i] + abs(h[... | replace | 4 | 5 | 4 | 5 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define f first
#define s second
int dp[10000];
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector<int> h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
dp[i] = 1e9;
}
dp[0]... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define f first
#define s second
int dp[1000000];
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector<int> h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
dp[i] = 1e9;
}
dp[... | replace | 7 | 8 | 7 | 8 | 0 | |
p03160 | C++ | Runtime Error | #include <cmath>
#include <iostream>
using namespace std;
int a[50], arr[50], n;
int topdown(int x);
int main() {
int ans;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
for (int i = 0; i < n; i++) {
a[i] = -1;
}
ans = topdown(0);
cout << ans;
return 0;
}
int topdown(int x) {
if (a... | #include <cmath>
#include <iostream>
using namespace std;
int a[100000], arr[100000], n;
int topdown(int x);
int main() {
int ans;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
for (int i = 0; i < n; i++) {
a[i] = -1;
}
ans = topdown(0);
cout << ans;
return 0;
}
int topdown(int x) {... | replace | 3 | 4 | 3 | 4 | 0 | |
p03160 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int INF = 0x3f3f3f3f;
;
vector<int> h(1e5 + 10);
vector<int> dp(1e5 + 10, INF);
int dfs(int j) {
if (j <= 0)
return 0;
if (j == 1) {
return abs(h[1] - h[0]);
}
if (j == 2) {
return abs(h[2] - h[0]);
}
if (dp[j] != INF)
return dp[j];
return mi... | #include <bits/stdc++.h>
using namespace std;
int INF = 0x3f3f3f3f;
;
vector<int> h(1e5 + 10);
vector<int> dp(1e5 + 10, INF);
int dfs(int j) {
if (j <= 0)
return 0;
if (j == 1) {
return abs(h[1] - h[0]);
}
if (j == 2) {
return abs(h[2] - h[0]);
}
if (dp[j] != INF)
return dp[j];
dp[j] =
... | replace | 19 | 21 | 19 | 22 | TLE | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int N;
vector<int> h(10010);
vector<int> dp(10010);
int res = 0;
cin >> N;
rep(i, N) { cin >> h.at(i); }
dp.at(1) = abs(h.at(1) - h.at(0));
for (int i = 2; i < N; i++) {
dp.at(i) = mi... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int N;
vector<int> h(100010);
vector<int> dp(100010);
int res = 0;
cin >> N;
rep(i, N) { cin >> h.at(i); }
dp.at(1) = abs(h.at(1) - h.at(0));
for (int i = 2; i < N; i++) {
dp.at(i) = ... | replace | 6 | 8 | 6 | 8 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
long long ans[10005], h[10005];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> h[i];
memset(ans, 63, sizeof(ans));
ans[0] = 0;
ans[1] = fabs(h[1] - h[0]);
for (int i = 2; i < n; i++)
ans[i] = min(ans[i - 2] + fabs(h[i - 2] - h[i]),
... | #include <bits/stdc++.h>
using namespace std;
long long ans[100005], h[100005];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> h[i];
memset(ans, 63, sizeof(ans));
ans[0] = 0;
ans[1] = fabs(h[1] - h[0]);
for (int i = 2; i < n; i++)
ans[i] = min(ans[i - 2] + fabs(h[i - 2] - h[i]),
... | replace | 2 | 3 | 2 | 3 | 0 | |
p03160 | C++ | Runtime Error | // #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define ull unsigned long long
typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#defi... | // #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define ull unsigned long long
typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#defi... | replace | 28 | 29 | 28 | 29 | 0 | |
p03160 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int a[100001];
int fib(int i, int n, int arr[]) {
if (i == n - 1) {
return 0;
}
int p = INT_MAX, q = INT_MAX;
if (i + 2 <= n - 1) {
p = fib(i + 2, n, arr) + abs(arr[i] - arr[i + 2]);
}
if (i + 1 <= n - 1) {
q = fib(i + 1, n, arr) ... | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int a[100001];
int fib(int i, int n, int arr[]) {
if (i == n - 1) {
return 0;
}
int p = INT_MAX, q = INT_MAX;
if (a[i] != -1) {
return a[i];
}
if (i + 2 <= n - 1) {
p = fib(i + 2, n, arr) + abs(arr[i] - arr[i + 2]);
}
if (i + ... | insert | 9 | 9 | 9 | 12 | TLE | |
p03160 | C++ | Runtime Error | #include "algorithm"
#include "cstring"
#include "ctime"
#include "iostream"
#include "map"
#include "math.h"
#include "numeric"
#include "queue"
#include "set"
#include "stack"
#include "string"
#include "vector"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/detail/standard_policies.hpp>... | #include "algorithm"
#include "cstring"
#include "ctime"
#include "iostream"
#include "map"
#include "math.h"
#include "numeric"
#include "queue"
#include "set"
#include "stack"
#include "string"
#include "vector"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/detail/standard_policies.hpp>... | replace | 97 | 98 | 97 | 98 | 0 | |
p03160 | C++ | Runtime Error | #include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
... | #include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
... | replace | 30 | 31 | 30 | 31 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main() {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++)
cin >> arr[i];
int dp[n];
dp[0] = 0;
dp[1] = abs(arr[1] - arr[0]);
if (n == 2)
return dp[n - 1];
for (int i = 2; i < n; i++) {
dp[i] = min(dp[i - 1]... | #include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main() {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++)
cin >> arr[i];
int dp[n];
dp[0] = 0;
dp[1] = abs(arr[1] - arr[0]);
if (n == 2) {
cout << dp[n - 1] << "\n";
return 0;
}
for (int i = 2; i < n; i++... | replace | 12 | 14 | 12 | 16 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
int dp[N];
int main() {
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
dp[0] = 0, dp[1] = abs(v[1] - v[0]);
for (int i = 2; i < n; i++) {
dp[i] =
min(dp[i - 1] + abs(v[i] - v[i - 1]... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int dp[N];
int main() {
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
dp[0] = 0, dp[1] = abs(v[1] - v[0]);
for (int i = 2; i < n; i++) {
dp[i] =
min(dp[i - 1] + abs(v[i] - v[i - 1]... | replace | 4 | 5 | 4 | 5 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mx 200005
#define fr first
#define se second
#define fast \
ios_base::sync_with_stdio(false); ... | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mx 200005
#define fr first
#define se second
#define fast \
ios_base::sync_with_stdio(false); ... | replace | 12 | 13 | 12 | 13 | 0 | |
p03160 | C++ | Runtime Error | #include "bits/stdc++.h"
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type,less<ll>,
// rb_tree_tag,tree_order_statistics_node_update>
// #include <boost/math/common_factor.cpp>
using namespace std;
#define fi... | #include "bits/stdc++.h"
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type,less<ll>,
// rb_tree_tag,tree_order_statistics_node_update>
// #include <boost/math/common_factor.cpp>
using namespace std;
#define fi... | replace | 107 | 108 | 107 | 108 | -6 | terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
|
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define int ll
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss ... | #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define int ll
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss ... | replace | 43 | 47 | 43 | 47 | TLE | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = ... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = ... | replace | 61 | 62 | 61 | 62 | 0 | |
p03160 | C++ | Runtime Error | #include <memory.h>
#include <stdio.h>
int max(int a, int b) {
if (a > b)
return a;
return b;
}
int min(int a, int b) {
if (a < b)
return a;
return b;
}
int abs(int a) {
if (a < 0)
return -a;
return a;
}
int h[10000];
int dp[10000];
int main() {
int N;
// freopen("input.txt", "r", stdin);
... | #include <memory.h>
#include <stdio.h>
int max(int a, int b) {
if (a > b)
return a;
return b;
}
int min(int a, int b) {
if (a < b)
return a;
return b;
}
int abs(int a) {
if (a < 0)
return -a;
return a;
}
int h[100000];
int dp[100000];
int main() {
int N;
// freopen("input.txt", "r", stdin);
... | replace | 17 | 19 | 17 | 19 | 0 | |
p03160 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int mem[MAXN], a[MAXN];
int n;
int solve(int i) {
if (i == n - 1)
return 0;
if (i >= n)
return 1e9;
int &ret = mem[i];
if (ret != -1)
return ret;
int c1 = 1e9, c2 = 1e9;
if (i + 1 < n)
c1 = solve(i + 1) + abs(a[i] - a... | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int mem[MAXN], a[MAXN];
int n;
int solve(int i) {
if (i == n - 1)
return 0;
if (i >= n)
return 1e9;
int &ret = mem[i];
if (ret != -1)
return ret;
int c1 = 1e9, c2 = 1e9;
if (i + 1 < n)
c1 = solve(i + 1) + abs(a[i] - a... | replace | 21 | 22 | 21 | 23 | TLE | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long a[10005], b[1005], x, y;
long long n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
b[n - 1] = abs(a[n] - a[n - 1]);
b[n] = 0;
for (int i = n - 2; i >= 1; i--) {
x = abs(a[i] ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long a[100005], b[100005], x, y;
long long n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
b[n - 1] = abs(a[n] - a[n - 1]);
b[n] = 0;
for (int i = n - 2; i >= 1; i--) {
x = abs(a[... | replace | 5 | 6 | 5 | 6 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for (ll i = a; i < b; i++)
void swap(ll &a, ll &b) {
ll t = a;
a = b;
b = t;
}
ll min(ll a, ll b) {
if (a < b)
return a;
return b;
}
ll max(ll a, ll b) {
if (a > b)
return a;
ret... | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9 + 7;
#define rep(i, a, b) for (ll i = a; i < b; i++)
void swap(ll &a, ll &b) {
ll t = a;
a = b;
b = t;
}
ll min(ll a, ll b) {
if (a < b)
return a;
return b;
}
ll max(ll a, ll b) {
if (a > b)
return a;
ret... | replace | 38 | 41 | 38 | 41 | -11 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define sz(v) (v).size()
#define debug(x) cerr << #x << "_=_" << x << "\n";
#define sum(n) ((n) * ((n) + 1) >> 1)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<pair<int, int>... | #include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define sz(v) (v).size()
#define debug(x) cerr << #x << "_=_" << x << "\n";
#define sum(n) ((n) * ((n) + 1) >> 1)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<pair<int, int>... | replace | 37 | 41 | 37 | 41 | -11 | |
p03160 | C++ | Runtime Error | #define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define read freopen("in.in", "r", stdin)
#define write freopen("out.out", "w", stdout)
#define FastIO ios::sync_with_stdio(0)
typedef long long ll;
int n;
int cost[100005];
int memo[100005];
int dp(int idx) {
if (idx > n)... | #define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define read freopen("in.in", "r", stdin)
#define write freopen("out.out", "w", stdout)
#define FastIO ios::sync_with_stdio(0)
typedef long long ll;
int n;
int cost[100005];
int memo[100005];
int dp(int idx) {
if (idx > n)... | replace | 27 | 29 | 27 | 28 | 0 | |
p03160 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int arr[n], dp[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
dp[i] = 0;
}
dp[1] = abs(arr[0] - arr[1]);
for (int i = 2; i < n; i++) {
dp[i] = min(dp[i - 2] + abs(arr[i - 2] - arr[i]),
dp[i - 1] + abs(arr... | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int arr[n], dp[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
dp[i] = 0;
}
dp[1] = abs(arr[0] - arr[1]);
for (int i = 2; i < n; i++) {
dp[i] = min(dp[i - 2] + abs(arr[i - 2] - arr[i]),
dp[i - 1] + abs(arr... | replace | 17 | 18 | 17 | 19 | 30 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long int
#define n 10005
using namespace std;
ll dp[n];
ll height[n];
ll solve(int N) {
dp[1] = 0;
for (int i = 2; i <= N; i++) {
ll opt1 = abs(height[i] - height[i - 1]) + dp[i - 1];
ll opt2 = (i == 2) ? INT_MAX : abs(height[i] - height[i - 2]) + dp[i - 2];
dp[i... | #include <bits/stdc++.h>
#define ll long long int
#define n 100005
using namespace std;
ll dp[n];
ll height[n];
ll solve(int N) {
dp[1] = 0;
for (int i = 2; i <= N; i++) {
ll opt1 = abs(height[i] - height[i - 1]) + dp[i - 1];
ll opt2 = (i == 2) ? INT_MAX : abs(height[i] - height[i - 2]) + dp[i - 2];
dp[... | replace | 2 | 3 | 2 | 3 | 0 | |
p03160 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
const long long INF = 1LL << 60;
/* bがa以上のとき、置き換え */
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
} else {
return false;
}
return true;
}
/* bがa以下のとき、置き... | #include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
const long long INF = 1LL << 60;
/* bがa以上のとき、置き換え */
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
} else {
return false;
}
return true;
}
/* bがa以下のとき、置き... | replace | 31 | 32 | 31 | 32 | 0 | |
p03160 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
typedef vector<ull> vul;
typ... | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
typedef vector<ull> vul;
typ... | replace | 20 | 21 | 20 | 21 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
int h[N], n, memo[N];
int solve(int idx) {
if (idx == n - 1)
return 0;
if (memo[idx] != -1)
return memo[idx];
int awal, tany = 1e9 + 5;
awal = abs(h[idx] - h[idx + 1]) + solve(idx + 1);
if (idx + 2 <= n - 1)
tany = abs(h[idx] - h... | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int h[N], n, memo[N];
int solve(int idx) {
if (idx == n - 1)
return 0;
if (memo[idx] != -1)
return memo[idx];
int awal, tany = 1e9 + 5;
awal = abs(h[idx] - h[idx + 1]) + solve(idx + 1);
if (idx + 2 <= n - 1)
tany = abs(h[idx] - h... | replace | 2 | 3 | 2 | 3 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int h[10004], dp[10004];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h[i];
}
dp[0] = 0;
dp[1] = abs(h[1] - h[0]);
for (int i = 2; i < n; i++) {
dp[i] =
min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + dp... | #include <bits/stdc++.h>
using namespace std;
int h[100005], dp[100005];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h[i];
}
dp[0] = 0;
dp[1] = abs(h[1] - h[0]);
for (int i = 2; i < n; i++) {
dp[i] =
min(abs(h[i] - h[i - 1]) + dp[i - 1], abs(h[i] - h[i - 2]) + ... | replace | 4 | 5 | 4 | 5 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll> dp(100002, -1);
ll n;
ll solve(vector<ll> &v, ll i) {
if (i == n - 1)
return 0;
if (dp[i] != -1)
return dp[i];
ll ans = abs(v[i] - v[i + 1]) + solve(v, i + 1);
if (i + 2 < n) {
ans = min(ans, abs(v[i] - v[i + 2]) + solve(v... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll> dp(100002, -1);
ll n;
ll solve(vector<ll> &v, ll i) {
if (i == n - 1)
return 0;
if (dp[i] != -1)
return dp[i];
ll ans = abs(v[i] - v[i + 1]) + solve(v, i + 1);
if (i + 2 < n) {
ans = min(ans, abs(v[i] - v[i + 2]) + solve(v... | replace | 14 | 15 | 14 | 15 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int memo[10005], h[10005], n;
int dp(int i) {
if (i > n)
return 1e5;
if (i == n)
return 0;
if (memo[i] != -1)
return memo[i];
int res, res1;
res = abs(h[i] - h[i + 1]) + dp(i + 1);
res1 = abs(h[i] - h[i + 2]) + dp(i + 2);
memo[i] = min(res, res1);... | #include <bits/stdc++.h>
using namespace std;
int memo[100005], h[100005], n;
int dp(int i) {
if (i > n)
return 1e5;
if (i == n)
return 0;
if (memo[i] != -1)
return memo[i];
int res, res1;
res = abs(h[i] - h[i + 1]) + dp(i + 1);
res1 = abs(h[i] - h[i + 2]) + dp(i + 2);
memo[i] = min(res, res1... | replace | 3 | 4 | 3 | 4 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define MX 20000... | #include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define MX 20000... | replace | 36 | 39 | 36 | 39 | -6 | terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
|
p03160 | C++ | Runtime Error | #pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(0); ... | #pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(0); ... | delete | 62 | 66 | 62 | 62 | -6 | terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
|
p03160 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long, long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i, a, b) for (ll i = a; i <... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long, long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i, a, b) for (ll i = a; i <... | replace | 49 | 50 | 49 | 51 | TLE | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define int lon... | #include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define int lon... | replace | 12 | 16 | 12 | 13 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ldb = long double;
using pa = pair<ll, ll>;
using vec = vector<ll>;
template <typename T>
using index_set =
tree<T, null_type, less<T... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ldb = long double;
using pa = pair<ll, ll>;
using vec = vector<ll>;
template <typename T>
using index_set =
tree<T, null_type, less<T... | replace | 46 | 50 | 46 | 50 | 0 | Time taken: 36ms
|
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
/*### FAST-IO ###*/
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout... | #include <bits/stdc++.h>
using namespace std;
/*### FAST-IO ###*/
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout... | replace | 235 | 239 | 235 | 239 | 0 | |
p03160 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll fun(ll a[], ll ind, ll dp[]) {
if (ind == 0)
return dp[0] = 0;
if (ind == 1)
return dp[1] = abs(a[0] - a[1]);
ll &ans = dp[ind];
return ans = min(abs(a[ind] - a[ind - 1]) + fun(a, ind - 1, dp),
abs(a[ind] - a[i... | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll fun(ll a[], ll ind, ll dp[]) {
if (ind == 0)
return dp[0] = 0;
if (ind == 1)
return dp[1] = abs(a[0] - a[1]);
ll &ans = dp[ind];
if (ans != -1)
return ans;
return ans = min(abs(a[ind] - a[ind - 1]) + fun(a, ind - 1, dp),
... | insert | 10 | 10 | 10 | 12 | TLE | |
p03160 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[100005];
ll ar[100005];
int n;
ll f(ll ind) {
if (ind == n)
return 0;
if (dp[ind] > 0)
return dp[ind];
ll a = f(ind + 1) + abs(ar[ind] - ar[ind + 1]);
ll b = 100000000000;
if (ind != n - 1) {
b = f(ind + 2) + abs(ar[ind] ... | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[100005];
ll ar[100005];
int n;
ll f(ll ind) {
if (ind == n)
return 0;
if (dp[ind] >= 0)
return dp[ind];
ll a = f(ind + 1) + abs(ar[ind] - ar[ind + 1]);
ll b = 100000000000;
if (ind != n - 1) {
b = f(ind + 2) + abs(ar[ind]... | replace | 9 | 10 | 9 | 10 | TLE | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 10000;
ll dp[N];
ll h[N];
const int mx = 1000000;
int main() {
ll n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h[i];
dp[i] = mx;
}
dp[0] = 0;
for (int i = 1; i < n; i++) {
if (i == 1) {
dp[i] = abs(h[i]... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1000000;
ll dp[N];
ll h[N];
const int mx = 1000000;
int main() {
ll n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> h[i];
dp[i] = mx;
}
dp[0] = 0;
for (int i = 1; i < n; i++) {
if (i == 1) {
dp[i] = abs(h[... | replace | 3 | 4 | 3 | 4 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
const long long INF = 1LL << 60;
template <typename T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b; // aをbで更新
return true;
}
return false;
}
int main(void) {
int n;
cin >> n;
vector<int> h(n);
for (int i = 0; i < n; i++)
... | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
const long long INF = 1LL << 60;
template <typename T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b; // aをbで更新
return true;
}
return false;
}
int main(void) {
int n;
cin >> n;
vector<int> h(n);
for (int i = 0; i < n; i++)
... | replace | 23 | 24 | 23 | 24 | 0 | |
p03160 | C++ | Runtime Error | // In The Name Of Allah
// Mehrkish Makuei
#include <bits/stdc++.h>
#define pb push_back
#define debug1(x) cerr << #x << " : " << x << endl;
#define debug2(x, y) \
cerr << #x << " : " << x << " " << #y << " : " << y << endl;
using namespace std;
typedef l... | // In The Name Of Allah
// Mehrkish Makuei
#include <bits/stdc++.h>
#define pb push_back
#define debug1(x) cerr << #x << " : " << x << endl;
#define debug2(x, y) \
cerr << #x << " : " << x << " " << #y << " : " << y << endl;
using namespace std;
typedef l... | replace | 20 | 21 | 20 | 21 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++)
cin >> v[i];
vector<int> dp(n);
dp[n - 2] = abs(v[n - 1] - v[n - 2]);
for (int i = n - 3; i >= 0; i++) {
dp[i] =
min(dp[i + 1] + abs(v[i + 1] - v[i]), dp[i + 2] + abs(... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++)
cin >> v[i];
vector<int> dp(n);
dp[n - 2] = abs(v[n - 1] - v[n - 2]);
for (int i = n - 3; i >= 0; i--) {
dp[i] =
min(dp[i + 1] + abs(v[i + 1] - v[i]), dp[i + 2] + abs(... | replace | 11 | 12 | 11 | 12 | -11 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <stdint.h>
using namespace std;
#define MOD 1e9 + 7
#define ll long long int
#define ff first
#define ss second
template <typename T, typename G>
ostream &operator<<(ostream &out, const pair<T, G> &a) {
return out << "( " << a.ff << ", " << a.ss << ")";
}
template <typename T> os... | #include <bits/stdc++.h>
#include <stdint.h>
using namespace std;
#define MOD 1e9 + 7
#define ll long long int
#define ff first
#define ss second
template <typename T, typename G>
ostream &operator<<(ostream &out, const pair<T, G> &a) {
return out << "( " << a.ff << ", " << a.ss << ")";
}
template <typename T> os... | delete | 54 | 61 | 54 | 54 | -6 | terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
|
p03160 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
const ll M = 1e5 + 6;
ll dp[M], a[M];
ll rec(ll index) {
if (index <= 2)
return dp[index];
if (dp[index] != -1)
return dp[index];
else
return min(abs(a[index] - a[index - 1]) + rec(index - 1),
a... | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
const ll M = 1e5 + 6;
ll dp[M], a[M];
ll rec(ll index) {
if (index <= 2)
return dp[index];
if (dp[index] != -1)
return dp[index];
else {
dp[index] = min(abs(a[index] - a[index - 1]) + rec(index - 1),
... | replace | 12 | 15 | 12 | 17 | TLE | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
void solve() {
int i, n;
cin >> n;
vector<int> v(n);
vector<int> dp(n, 0);
for (i = 0; i < n; i++)
cin >> v[i];
dp[0] = 0;
dp[1] = abs(v[1] - v[0]);
if (n == 1) {
cout << dp[0] << "\n";
return;
}
if (n == 2) {
cout << dp[1] << "\n";
... | #include <bits/stdc++.h>
using namespace std;
void solve() {
int i, n;
cin >> n;
vector<int> v(n);
vector<int> dp(n, 0);
for (i = 0; i < n; i++)
cin >> v[i];
dp[0] = 0;
dp[1] = abs(v[1] - v[0]);
if (n == 1) {
cout << dp[0] << "\n";
return;
}
if (n == 2) {
cout << dp[1] << "\n";
... | replace | 28 | 32 | 28 | 29 | -6 | terminate called after throwing an instance of 'std::length_error'
what(): cannot create std::vector larger than max_size()
|
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define all(x) x.begin(), x.end()
typedef pair<int, int> pi;
typedef long long ll;
const int MAX_INT = 2000000000;
int dp[100001];
int h[1000... | #include <bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define all(x) x.begin(), x.end()
typedef pair<int, int> pi;
typedef long long ll;
const int MAX_INT = 2000000000;
int dp[100001];
int h[1000... | replace | 28 | 29 | 28 | 29 | -11 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define pan(i, n) for (int i = 0; i < n; i++)
#define pans(i, n, a) for (int i = a; i < n; i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define pll pair<ll,... | #include <bits/stdc++.h>
using namespace std;
#define pan(i, n) for (int i = 0; i < n; i++)
#define pans(i, n, a) for (int i = a; i < n; i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define pll pair<ll,... | replace | 24 | 26 | 24 | 26 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define lli long long int
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n;
cin >> n;
vector<int> h(n), v(n);
for (auto &it : h)
cin >>... | #include <bits/stdc++.h>
using namespace std;
#define lli long long int
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> h(n), v(n);
for (auto &it : h)
cin >> it;
v[0] = 0;
v[1] = abs(h[1] - h[0]);
for (int i = 2; i < n; ++i) {
v[i] =
min(a... | delete | 8 | 12 | 8 | 8 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
int h[10002];
int dp[10002];
cin >> N;
for (int i = 0; i < N; i++) {
cin >> h[i];
dp[i] = 0;
}
dp[1] = abs(h[1] - h[0]);
for (int i = 2; i < N; ++i) {
dp[i] =
min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i]... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
int h[100002];
int dp[100002];
cin >> N;
for (int i = 0; i < N; i++) {
cin >> h[i];
dp[i] = 0;
}
dp[1] = abs(h[1] - h[0]);
for (int i = 2; i < N; ++i) {
dp[i] =
min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[... | replace | 5 | 7 | 5 | 7 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void print(ll x[], ll n) {
for (int i = 0; i < n; i++)
cout << x[i] << " ";
cout << endl;
}
int x[10009], n;
int dp[100009];
ll cost(int i) {
if (i == n - 1)
return 0;
if (i >= n)
return 100000000000;
if (dp[i] != -1)
return ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void print(ll x[], ll n) {
for (int i = 0; i < n; i++)
cout << x[i] << " ";
cout << endl;
}
int x[100009], n;
int dp[100009];
ll cost(int i) {
if (i == n - 1)
return 0;
if (i >= n)
return 100000000000;
if (dp[i] != -1)
return... | replace | 9 | 10 | 9 | 10 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int h[10005];
int dp[10005];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> h[i];
}
dp[0] = 0;
dp[1] = abs(h[1] - h[0]);
for (int i = 2; i < N; i++) {
dp[i] =
min(abs(h[i] ... | #include <bits/stdc++.h>
using namespace std;
int h[100005];
int dp[100005];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> h[i];
}
dp[0] = 0;
dp[1] = abs(h[1] - h[0]);
for (int i = 2; i < N; i++) {
dp[i] =
min(abs(h[i... | replace | 3 | 5 | 3 | 5 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int dp[10001];
int main() {
#ifdef EVAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int N;
cin >> N;
int vet[N];
for (int i = 0; i < N; i++) {
cin >> vet[i];
}
fill(dp, dp + N, INT_MAX);
dp[0] = 0;
for (int i = 0; i <... | #include <bits/stdc++.h>
using namespace std;
int dp[100001];
int main() {
#ifdef EVAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int N;
cin >> N;
int vet[N];
for (int i = 0; i < N; i++) {
cin >> vet[i];
}
fill(dp, dp + N, INT_MAX);
dp[0] = 0;
for (int i = 0; i ... | replace | 2 | 3 | 2 | 3 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int dp[1000], vet[100005];
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d", &vet[i]);
memset(dp, 0x3f3f3f3f, sizeof dp);
dp[(n - 1)] = 0;
for (int i = n - 2; i >= 0; i--) {
dp[i] = min(dp[i], dp[i + 1] + abs(vet[i] - vet[i + ... | #include <bits/stdc++.h>
using namespace std;
int dp[100005], vet[100005];
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%d", &vet[i]);
memset(dp, 0x3f3f3f3f, sizeof dp);
dp[(n - 1)] = 0;
for (int i = n - 2; i >= 0; i--) {
dp[i] = min(dp[i], dp[i + 1] + abs(vet[i] - vet[i ... | replace | 3 | 4 | 3 | 4 | 0 | |
p03160 | C++ | Runtime Error | // Author rahuliitkgp
/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
// Men at Work :)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define ff first
#define ss second
... | // Author rahuliitkgp
/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
// Men at Work :)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define ff first
#define ss second
... | replace | 39 | 43 | 39 | 43 | -6 | terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
|
p03160 | C++ | Runtime Error | /**
* purpose :
* author : kyomukyomupurin
* created :
**/
// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#inclu... | /**
* purpose :
* author : kyomukyomupurin
* created :
**/
// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#inclu... | replace | 58 | 60 | 58 | 60 | 0 | |
p03160 | C++ | Runtime Error | #include <iostream>
using namespace std;
#include <vector>
int main() {
int n;
cin >> n;
const int INF = 1e9 + 7;
vector<long long int> h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
}
vector<long long int> s(n, INF);
s[0] = 0;
for (long long int i = 0; i < n; i++) {
for (long long int j = ... | #include <iostream>
using namespace std;
#include <vector>
int main() {
int n;
cin >> n;
const int INF = 1e9 + 7;
vector<long long int> h(n);
for (int i = 0; i < n; i++) {
cin >> h[i];
}
vector<long long int> s(n, INF);
s[0] = 0;
for (long long int i = 0; i < n; i++) {
for (long long int j = ... | 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)
|
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
long long arr[10010];
vector<long long> distance(10010, INT_MAX);
for (int i = 0; i < n; i++)
cin >> arr[i];
distance[0] = 0ll;
for (int i = 0; i < n; i++) {
if (i + 1 < n)
distance[i + 1] =
min... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
vector<long long> arr(n);
vector<long long> distance(n, INT_MAX);
for (int i = 0; i < n; i++)
cin >> arr[i];
distance[0] = 0ll;
for (int i = 0; i < n; i++) {
if (i + 1 < n)
distance[i + 1] =
min... | replace | 7 | 9 | 7 | 9 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define vi vector<int>
#define usi unordered_set<int>
#define si set<int>
#define umii unordered_map<int, int>
#define mii map<int, int>
#define all(a) a.begin(), a.end()
#define vii vector<pair<int, int>>
#define pii pair<int, in... | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define vi vector<int>
#define usi unordered_set<int>
#define si set<int>
#define umii unordered_map<int, int>
#define mii map<int, int>
#define all(a) a.begin(), a.end()
#define vii vector<pair<int, int>>
#define pii pair<int, in... | replace | 17 | 23 | 17 | 23 | -11 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(s) s.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i, a, n) for (int i = a; i < n; i++)
using namespace std;
typedef lo... | #include <bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define MOD 1000000007
#define len(s) s.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define f(i, a, n) for (int i = a; i < n; i++)
using namespace std;
typedef lo... | replace | 17 | 21 | 17 | 21 | -6 | terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
|
p03160 | C++ | Time Limit Exceeded |
#include <bits/stdc++.h>
#include <time.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" ... |
#include <bits/stdc++.h>
#include <time.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) \
cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" ... | replace | 50 | 52 | 50 | 56 | TLE | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag,
tree_order_statistics_node_update>; template<typename T, typename L> using
gpp_map = tre... | #include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag,
tree_order_statistics_node_update>; template<typename T, typename L> using
gpp_map = tre... | replace | 109 | 111 | 109 | 110 | 0 | |
p03160 | C++ | Runtime Error | /*huzaifa242 copyright*/
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535897932384626
#define mod 1000000007
#define MAX 100005
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
i... | /*huzaifa242 copyright*/
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535897932384626
#define mod 1000000007
#define MAX 100005
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifdef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
in... | replace | 9 | 10 | 9 | 10 | -11 | |
p03160 | C++ | Runtime Error | // gauravsinghh
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sii set<int>... | // gauravsinghh
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sii set<int>... | replace | 86 | 88 | 86 | 90 | 0 | |
p03160 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(... | #include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(... | replace | 41 | 43 | 41 | 43 | TLE | |
p03160 | C++ | Runtime Error | // gauravsinghh
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using bigint = int64_t;
#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#defi... | // gauravsinghh
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using bigint = int64_t;
#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#defi... | replace | 75 | 76 | 75 | 76 | 0 | |
p03160 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define lcm(a, b) (a) / __gcd((a), (b)) * (b)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define maxn 10000000000000
#define endl '\n'
#define trace(x) cer... | #include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define lcm(a, b) (a) / __gcd((a), (b)) * (b)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define maxn 10000000000000
#define endl '\n'
#define trace(x) cer... | insert | 43 | 43 | 43 | 44 | TLE | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, f, n) for (int i = f; i < n; i++)
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
int d[10000];
fill(d, d + n, 0);
rep(i, n) cin >> a.at(i);
d[1] ... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, f, n) for (int i = f; i < n; i++)
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
int d[100005];
fill(d, d + n, 0);
rep(i, n) cin >> a.at(i);
d[1]... | replace | 11 | 12 | 11 | 12 | 0 | |
p03160 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> v;
vector<int> cost;
for (int i = 1; i < n + 1; ++i) {
cin >> v[i];
}
cost[1] = 0;
cost[2] = cost[1] + abs(v[1] - v[2]);
for... | #include <algorithm>
#include <bitset>
#include <iostream>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> v(n + 1, 0);
vector<int> cost(n + 1, 0);
for (int i = 1; i < n + 1; ++i) {
cin >> v[i];
}
cost[1] = 0;
cost[2] = cost[1] + abs... | replace | 11 | 13 | 11 | 13 | -11 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
vector<int> height;
vector<int> dp(N);
cin >> N;
int x;
for (int i = 0; i < N; i++) {
cin >> x;
height.push_back(x);
}
dp[0] = 0;
dp[1] = abs(height[0] - height[1]);
for (int i = 2; i < N; i++)
dp[i] = min(dp[i - 1] + ab... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
vector<int> height;
vector<int> dp(N);
cin >> N;
int x;
for (int i = 0; i < N; i++) {
cin >> x;
height.push_back(x);
}
dp[0] = 0;
dp[1] = abs(height[0] - height[1]);
for (int i = 2; i < N; i++)
dp[i] = min(dp[i - 1] + ab... | replace | 20 | 21 | 20 | 21 | -6 | terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
|
p03160 | 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 | 22 | 24 | 22 | 24 | -11 | |
p03160 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
long long int f(int *h, int i) {
if (i <= 0)
return 0;
if (i == 1)
return abs(h[i] - h[0]);
long long int ans1 = f(h, i - 2) + abs(h[i] - h[i - 2]);
long long int ans2 = f(h, i - 1) + abs(h[i] - h[i - 1]);
return min(ans1, ans2);
}
int main() {
int n;
... | #include <bits/stdc++.h>
using namespace std;
long long int f(int *h, int i) {
if (i <= 0)
return 0;
if (i == 1)
return abs(h[i] - h[0]);
long long int ans1 = f(h, i - 2) + abs(h[i] - h[i - 2]);
long long int ans2 = f(h, i - 1) + abs(h[i] - h[i - 1]);
return min(ans1, ans2);
}
int main() {
int n;
... | replace | 17 | 23 | 17 | 25 | TLE | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i, j;
cin >> n;
vector<int> dp(n), h(n);
for (i = 0; i < n; i++) {
cin >> h[i];
}
for (i = 0; i < n; ++i) {
if (i != 0) {
dp[i + 1] = min(dp[i] + abs(h[i] - h[i + 1]),
dp[i - 1] + abs(h[i + 1] - h[i - 1]... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, i, j;
cin >> n;
vector<int> dp(n), h(n);
for (i = 0; i < n; i++) {
cin >> h[i];
}
for (i = 0; i < n - 1; ++i) {
if (i != 0) {
dp[i + 1] = min(dp[i] + abs(h[i] - h[i + 1]),
dp[i - 1] + abs(h[i + 1] - h[i ... | replace | 12 | 13 | 12 | 13 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, temp;
cin >> n;
vector<int> h(n, 0);
for (int i = 0; i < n; i++) {
cin >> temp;
h[i] = temp;
}
vector<int> dp(n + 1, INT_MAX);
dp[0] = 0;
dp[1] = abs(h[1] - h[0]);
for (int i = 2; i < n; i++) {
dp[i] =
min(dp[i - 1] ... | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, temp;
cin >> n;
vector<int> h(n, 0);
for (int i = 0; i < n; i++) {
cin >> temp;
h[i] = temp;
}
vector<int> dp(n + 1, INT_MAX);
dp[0] = 0;
dp[1] = abs(h[1] - h[0]);
for (int i = 2; i < n; i++) {
dp[i] =
min(dp[i - 1] ... | replace | 17 | 18 | 17 | 18 | 30 | |
p03160 | C++ | Runtime Error | #include <cstdio>
#include <iostream>
using namespace std;
int n, a[100001], f[100001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("FROG1.inp", "r", stdin);
freopen("FROG1.out", "w", stdout);
#endif // ONLINE_JUDGE
cin >> n;
for (int i = 1; i <= n; i... | #include <cstdio>
#include <iostream>
using namespace std;
int n, a[100001], f[100001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
f[1] = 0;
f[2] = abs(a[2] - a[1]);
for (int i = 3; i <= n; i++) {
f[i] =
... | delete | 10 | 14 | 10 | 10 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, n, m) for (int i = (n); i < (m); i++)
#define REP(i, n) FOR(i, 0, n)
#define nax 10009
typedef vector<int> vi;
int main() {
int n, dp[nax];
cin >> n;
vi v(n);
REP(i, n) cin >> v[i];
memset(dp, 100000000, sizeof dp);
dp[0] = 0;
dp[1] = abs(v[... | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, n, m) for (int i = (n); i < (m); i++)
#define REP(i, n) FOR(i, 0, n)
#define nax 100009
typedef vector<int> vi;
int main() {
int n, dp[nax];
cin >> n;
vi v(n);
REP(i, n) cin >> v[i];
memset(dp, 100000000, sizeof dp);
dp[0] = 0;
dp[1] = abs(v... | replace | 5 | 6 | 5 | 6 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <math.h>
#define pb push_back
#define fst first
#define snd second
#define fill(a, c) memset(&a, c, sizeof(a))
#define fore(i, x, y) for (ll i = x; i < y; i++)
#define FIN \
ios_base::sync_with_stdio(0); ... | #include <bits/stdc++.h>
#include <math.h>
#define pb push_back
#define fst first
#define snd second
#define fill(a, c) memset(&a, c, sizeof(a))
#define fore(i, x, y) for (ll i = x; i < y; i++)
#define FIN \
ios_base::sync_with_stdio(0); ... | delete | 18 | 21 | 18 | 18 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define loop(i, a, b) for (int i = (a); i < (b); i++)
#define loopb(i, b, a) for (int i = (b); i > (a); --i)
void fastscan(int &x) {
bool neg = false;
register int c;
x = 0;
c = ... | #include <bits/stdc++.h>
using namespace std;
#define END '\n'
#define int long long
#define pb push_back
#define pii pair<int, int>
#define loop(i, a, b) for (int i = (a); i < (b); i++)
#define loopb(i, b, a) for (int i = (b); i > (a); --i)
void fastscan(int &x) {
bool neg = false;
register int c;
x = 0;
c = ... | delete | 30 | 38 | 30 | 30 | -6 | |
p03160 | C++ | Runtime Error | // Author: nimishkhurana
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (i = a; i < b; i++)
#define rrep(i, b, a) for (i = b; i >= a; i--)
#define ld long double
#define ll long long
#define umapi unordered_map<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
... | // Author: nimishkhurana
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (i = a; i < b; i++)
#define rrep(i, b, a) for (i = b; i >= a; i--)
#define ld long double
#define ll long long
#define umapi unordered_map<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
... | replace | 56 | 61 | 56 | 61 | 0 | |
p03160 | C++ | Runtime Error | // Author: nimishkhurana
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (i = a; i < b; i++)
#define rrep(i, b, a) for (i = b; i >= a; i--)
#define ld long double
#define ll long long
#define umapi unordered_map<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
... | // Author: nimishkhurana
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (i = a; i < b; i++)
#define rrep(i, b, a) for (i = b; i >= a; i--)
#define ld long double
#define ll long long
#define umapi unordered_map<int, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
... | replace | 44 | 49 | 44 | 49 | 0 | |
p03160 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> h(N);
for (int i = 1; i <= N; i++) {
cin >> h[i];
}
int answer = 0;
vector<int> dp(N + 1);
dp[0] = 0;
dp[1] = 0;
dp[2] = abs(h[1] - h[2]);
for (int i = 3; i <= N; i++) {
dp[i] =
min(abs(... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<int> h(N + 1);
for (int i = 1; i <= N; i++) {
cin >> h[i];
}
int answer = 0;
vector<int> dp(N + 1);
dp[0] = 0;
dp[1] = 0;
dp[2] = abs(h[1] - h[2]);
for (int i = 3; i <= N; i++) {
dp[i] =
min(... | replace | 8 | 9 | 8 | 9 | 0 | |
p03160 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>... | #include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>... | replace | 156 | 161 | 156 | 161 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.