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
p02257
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; bool is_prime(int num) { for (int i = 2; i < num; i++) { if (num % i == 0) { return false; } } return true; } int main(void) { int n; cin >> n; int num; int prime_count = 0;...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; bool is_prime(int num) { int a = sqrt(num); for (int i = 2; i <= a; i++) { if (num % i == 0) { return false; } } return true; } int main(void) { int n; cin >> n; int num; ...
replace
8
9
8
11
TLE
p02257
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; bool isprime(int x); int main() { int i, j; int a, n; int ans = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a; if (isprime(a) == true) ans++; } cout << ans << "\n"; return (0); } bool isprime(int x) { int i = 3; if (x == 2) r...
#include <bits/stdc++.h> using namespace std; bool isprime(int x); int main() { int i, j; int a, n; int ans = 0; cin >> n; for (i = 0; i < n; i++) { cin >> a; if (isprime(a) == true) ans++; } cout << ans << "\n"; return (0); } bool isprime(int x) { int i = 3; if (x == 2) r...
insert
35
35
35
36
TLE
p02257
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <math.h> #include <sstream> #include <stdio.h> #include <string> using namespace std; int GCD(int x, int y) { if (y == 0) { return x; } return GCD(y, x % y); } bool isPrime(int N) { for (int i = 2; i < N; i++) { if (GCD(N, i) != 1) return false;...
#include <algorithm> #include <iostream> #include <math.h> #include <sstream> #include <stdio.h> #include <string> using namespace std; int GCD(int x, int y) { if (y == 0) { return x; } return GCD(y, x % y); } bool isPrime(int N) { if (N == 2) true; if (N % 2 == 0) false; for (int i = 2; i * ...
replace
17
18
17
22
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> #include <math.h> #include <string> using namespace std; bool prime(int); int main() { int n, k, c = 0; cin >> n; while (n--) { cin >> k; if (prime(k)) c++; } cout << c << endl; return 0; } bool prime(int a) { for (int i = 2; i < a; i++) { if (a % i == 0) ret...
#include <iostream> #include <math.h> #include <string> using namespace std; bool prime(int); int main() { int n, k, c = 0; cin >> n; while (n--) { cin >> k; if (prime(k)) c++; } cout << c << endl; return 0; } bool prime(int a) { for (int i = 2; i < (int)(sqrt((double)a)) + 1; i++) { ...
replace
20
21
20
21
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int N, a, ans = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> a; bool flag = true; if (a != 2 && a % 2 == 0 || a == 1) { flag = false; } else if (a != 2) { for (int j = 3; j < a; j += 2) { if (a % j == 0) { fl...
#include <iostream> using namespace std; int main() { int N, a, ans = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> a; bool flag = true; if (a != 2 && a % 2 == 0 || a == 1) { flag = false; } else if (a > 2) { for (int j = 3; j * j <= a; j += 2) { if (a % j == 0) { ...
replace
11
13
11
13
TLE
p02257
C++
Time Limit Exceeded
#include <algorithm> #include <cstdlib> #include <iomanip> #include <iostream> #include <list> #include <map> #include <string> #include <typeinfo> #include <vector> #define _USE_MATH_DEFINES #include <cmath> using namespace std; // prime=>true, not prime=>false // bool isPrime(int i){ // for(int j=2; j<=i/2; j++...
#include <algorithm> #include <cstdlib> #include <iomanip> #include <iostream> #include <list> #include <map> #include <string> #include <typeinfo> #include <vector> #define _USE_MATH_DEFINES #include <cmath> using namespace std; // prime=>true, not prime=>false // bool isPrime(int i){ // for(int j=2; j<=i/2; j++...
replace
33
34
33
34
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> #include <math.h> #include <string> using namespace std; int main() { int n, m; ; cin >> m; int count = m; for (int s = 0; s < m; s++) { cin >> n; if (n == 2) continue; else if (n % 2 == 0) count--; else { for (int i = 3; i < n; i += 2) { if (n % ...
#include <iostream> #include <math.h> #include <string> using namespace std; int main() { int n, m; ; cin >> m; int count = m; for (int s = 0; s < m; s++) { cin >> n; if (n == 2) continue; else if (n % 2 == 0) count--; else { for (int i = 3; i <= sqrt(n); i += 2) { i...
replace
17
18
17
18
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> using namespace std; bool heheda(int a); bool heheda(int a) { for (int i = 2; i * 2 <= a; i++) if (!(a % i)) return false; return true; } int main() { int n; cin >> n; int tmp2 = 0; int c; for (int i = 0; i < n; i++) { cin >> c; if (heheda(c)) tmp2 += 1; } ...
#include <iostream> using namespace std; bool heheda(int a); bool heheda(int a) { for (int i = 2; i * i <= a; i++) if (!(a % i)) return false; return true; } int main() { int n; cin >> n; int tmp2 = 0; int c; for (int i = 0; i < n; i++) { cin >> c; if (heheda(c)) tmp2 += 1; } ...
replace
5
6
5
6
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> #include <math.h> using namespace std; int main() { int n, i, x, j, flag = 0, cut = 0, a; cin >> n; for (i = 0; i < n; i++) { cin >> x; a = sqrt(x); flag = 0; for (j = x - 1; j > 1; j--) { if (x % j == 0) { flag = 1; break; } } if (flag == 0)...
#include <iostream> #include <math.h> using namespace std; int main() { int n, i, x, j, flag = 0, cut = 0, a; cin >> n; for (i = 0; i < n; i++) { cin >> x; a = sqrt(x); flag = 0; for (j = a; j > 1; j--) { if (x % j == 0) { flag = 1; break; } } if (flag == 0) ...
replace
10
11
10
11
TLE
p02257
C++
Time Limit Exceeded
#include <algorithm> #include <array> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; int main(void) { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int cnt = 0; for (int...
#include <algorithm> #include <array> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <sstream> #include <string> #include <vector> using namespace std; int main(void) { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int cnt = 0; for (int...
replace
35
36
35
36
TLE
p02257
C++
Time Limit Exceeded
#include <cmath> #include <iostream> using namespace std; bool isPrime(int a) { for (int i = 2; i < a; i++) { if (a % i == 0) { return false; } } return true; } int main() { int n; cin >> n; int sum = 0; int x; for (int i = 0; i < n; i++) { cin >> x; if (isPrime(x)) sum ...
#include <cmath> #include <iostream> using namespace std; bool isPrime(int a) { for (int i = 2; i <= sqrt(a); i++) { if (a % i == 0) { return false; } } return true; } int main() { int n; cin >> n; int sum = 0; int x; for (int i = 0; i < n; i++) { cin >> x; if (isPrime(x)) ...
replace
5
6
5
6
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main(void) { bool flag; int n, k = 0, a; cin >> n; for (int i = 0; i < n; i++) { cin >> a; flag = false; for (int j = a - 1; 1 < j; j--) { if (a % j == 0) { flag = true; break; } } if (flag == false) k += 1; } ...
#include <iostream> using namespace std; int main(void) { bool flag; int n, k = 0, a; cin >> n; for (int i = 0; i < n; i++) { cin >> a; flag = false; for (int j = 2; j * j <= a; j++) { if (a % j == 0) { flag = true; break; } } if (flag == false) k += 1; } ...
replace
9
10
9
10
TLE
p02257
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <map> #include <numeric> #include <set> #include <sstream> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; typedef long long ll; in...
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <map> #include <numeric> #include <set> #include <sstream> #include <string> #include <tuple> #include <utility> #include <vector> using namespace std; typedef long long ll; in...
replace
28
29
28
29
TLE
p02257
C++
Runtime Error
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <queue> #include <stack> #include <string> #include <utility> #include <vector> #define rep(n) for (int i = 0; i < (n); i++) #define pb(n) push_back((n)) // typedef long long ll; using namespace...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <queue> #include <stack> #include <string> #include <utility> #include <vector> #define rep(n) for (int i = 0; i < (n); i++) #define pb(n) push_back((n)) // typedef long long ll; using namespace...
replace
36
37
36
37
-8
p02257
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int a, d = 0; cin >> a; for (int i = 0; i < a; i++) { int b; cin >> b; d++; for (int j = 2; j < b / 2 + 1; j++) { if (b % j == 0) { d--; break; } } } cout << d << endl; }
#include <iostream> using namespace std; int main() { int a, d = 0; cin >> a; for (int i = 0; i < a; i++) { int b; cin >> b; d++; for (int j = 2; j * j <= b; j++) { if (b % j == 0) { d--; break; } } } cout << d << endl; }
replace
11
12
11
12
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> using namespace std; int n; int a; int p = 0; void is_prime() { for (int i = 2; i <= a / 2; i++) { if (a % i == 0) { return; } } p++; } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a; is_prime(); } cout << p << endl; return 0; }
#include <iostream> using namespace std; int n; int a; int p = 0; void is_prime() { for (int i = 2; i * i <= a; i++) { if (a % i == 0) { return; } } p++; } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a; is_prime(); } cout << p << endl; return 0; }
replace
7
8
7
8
TLE
p02257
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; bool IsPrime(int a) { if (a == 2) return true; if (a % 2 == 0) { return false; } for (int i = 3; i < a; i += 2) { if (a % i == 0) { return false; } } return true; } int ...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <vector> using namespace std; bool IsPrime(int a) { if (a == 2) return true; if (a % 2 == 0) { return false; } for (int i = 3; i <= sqrt(a); i += 2) { if (a % i == 0) { return false; } } return true;...
replace
13
14
13
14
TLE
p02257
C++
Time Limit Exceeded
#include <cmath> #include <cstdio> #include <iostream> using namespace std; bool isPrime(int x) { if (x == 2) return true; if (x % 2 == 0) return false; int i = 3; while (i <= sqrt(x)) { if (x % i == 0) return false; } return true; } int main() { int n; scanf("%d", &n); int x[n];...
#include <cmath> #include <cstdio> #include <iostream> using namespace std; bool isPrime(int x) { if (x == 2) return true; if (x % 2 == 0) return false; int i = 3; while (i <= sqrt(x)) { if (x % i == 0) return false; ++i; } return true; } int main() { int n; scanf("%d", &n); ...
insert
15
15
15
16
TLE
p02257
C++
Time Limit Exceeded
#include <iostream> #include <math.h> using namespace std; int gcd(int a1, int b1) { if (a1 == 0 || b1 == 0) { return 0; } if (a1 >= b1) { if (a1 % b1 == 0) { return b1; } else { return gcd(b1, a1 % b1); } } else { if (b1 % a1 == 0) { return a1; } else { return gc...
#include <iostream> #include <math.h> using namespace std; int gcd(int a1, int b1) { if (a1 == 0 || b1 == 0) { return 0; } if (a1 >= b1) { if (a1 % b1 == 0) { return b1; } else { return gcd(b1, a1 % b1); } } else { if (b1 % a1 == 0) { return a1; } else { return gc...
replace
37
38
37
38
TLE
p02257
C++
Time Limit Exceeded
#include <cmath> #include <iostream> #include <vector> using namespace std; bool Sieve(int x) { for (int i = 2; i <= sqrt(x); i++) if (x % i == 0) return false; return true; } int main() { int n; vector<int> items; // input cin >> n; items.resize(n); for (int i = 0; i < n; i++) cin >> it...
#include <cmath> #include <iostream> #include <vector> using namespace std; bool Sieve(int x) { for (int i = 2; i <= sqrt(x); i++) if (x % i == 0) return false; return true; } int main() { int n; vector<int> items; // input cin >> n; items.resize(n); for (int i = 0; i < n; i++) cin >> it...
replace
23
25
23
25
TLE
p02257
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdint> #include <iomanip> #include <iostream> #include <numeric> #include <string> #include <vector> using namespace std; bool isPrime(int x) { for (int i = 2; i < x; ++i) { if (x % i == 0) { return false; } } return true; } int main() { int n, ...
#include <algorithm> #include <cmath> #include <cstdint> #include <iomanip> #include <iostream> #include <numeric> #include <string> #include <vector> using namespace std; bool isPrime(int x) { int max = sqrt(x); for (int i = 2; i <= max; ++i) { if (x % i == 0) { return false; } } return true; }...
replace
12
13
12
14
TLE
p02257
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <vector> bool isPrime(std::size_t a) { if (a == 2) { return true; } else if (a % 2 == 0) { return false; } for (std::size_t i = 3; i < a / 2; i = i + 2) { if (a % i == 0) { return false; } } return...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <vector> bool isPrime(std::size_t a) { if (a == 2) { return true; } else if (a % 2 == 0) { return false; } for (std::size_t i = 3; i <= (std::size_t)(sqrt(a)); i = i + 2) { if (a % i == 0) { return false; ...
replace
13
14
13
14
TLE
p02257
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> using namespace std; int main() { int N; cin >> N; int cnt = 0; int num = 0; for (int i = 0; i < N; i++) { cin >> num; for (int j = 1; j < num; j++) { if (j == 1) { continue; } if (num % j == 0) { num = 0; break; ...
#include <algorithm> #include <iostream> using namespace std; int main() { int N; cin >> N; int cnt = 0; int num = 0; for (int i = 0; i < N; i++) { cin >> num; if (num == 2) { cnt += 1; continue; } if (num % 2 == 0) { continue; } double sqrtnum = sqrt(num); for...
replace
12
16
12
22
TLE
p02257
C++
Time Limit Exceeded
#include <cassert> #include <iostream> #include <math.h> using namespace std; bool isPrime(int x) { if (x < 2) return false; else if (x == 2) return true; if (x % 2 == 0) return false; int limit = (int)sqrt((double)x) + 1; for (int i = 3; i < x / 2; i += 2) { if (x % i == 0) return fals...
#include <cassert> #include <iostream> #include <math.h> using namespace std; bool isPrime(int x) { if (x < 2) return false; else if (x == 2) return true; if (x % 2 == 0) return false; int limit = (int)sqrt((double)x) + 1; for (int i = 3; i <= limit; i += 2) { if (x % i == 0) return fal...
replace
13
14
13
14
TLE
p02258
C++
Time Limit Exceeded
#include <iostream> #define INT_MIN -2000000000 #define MAX_R 200001 using namespace std; int main() { int n, k; while (cin >> n) { int max = INT_MIN; int r[MAX_R]; k = n; while (k--) { cin >> r[k]; } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (r[...
#include <iostream> #define INT_MIN -2000000000 #define MAX_R 200001 using namespace std; int main() { int n, k; while (cin >> n) { int max = INT_MIN; int r[MAX_R]; k = n; while (k--) { cin >> r[k]; } for (int i = 0; i < n; i++) { if (r[i] < max) continue; for (int...
insert
15
15
15
17
TLE
p02258
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 1e9; int main() { int n = 0; fscanf(stdin, "%d", &n); vector<ll> v(n); for (int i = 0; i < n; ++i) { fscanf(stdin, "%lld", &v[i]); } ll ans = -INF; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 1e9; int main() { int n = 0; fscanf(stdin, "%d", &n); vector<ll> v(n); for (int i = 0; i < n; ++i) { fscanf(stdin, "%lld", &v[i]); } ll ans = -INF; ll mn = v[0]; for (int i = 1; i < n; ++i) { ans = max(ans, v...
replace
16
20
16
20
TLE
p02258
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 200000; int main() { int num = 0, maxProfit = -1000000000; int value[MAX] = {0}; cin >> num; for (int i = 0; i < num; i++) { cin >> value[i]; } for (int i = 0; i < num; i++) { for (int j = i + 1; j < num; j++) ...
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 200000; int main() { int num = 0, maxProfit = -1000000000; int value[MAX] = {0}; cin >> num; for (int i = 0; i < num; i++) { cin >> value[i]; } int minValue = value[0]; for (int i = 1; i < num; i++) { maxPro...
replace
16
20
16
21
TLE
p02258
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; typedef vector<ll> Vector; typedef vector<vector<ll>> DVector; #define fi first #define se second #define pb push_back #define INF INT_MAX #define bcnt __builtin_popcount #define all(x) (x).begi...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; typedef vector<ll> Vector; typedef vector<vector<ll>> DVector; #define fi first #define se second #define pb push_back #define INF INT_MAX #define bcnt __builtin_popcount #define all(x) (x).begi...
replace
38
39
38
42
TLE
p02258
C++
Runtime Error
#include "bits/stdc++.h" using namespace std; int main() { int n; cin >> n; vector<int> R(n); for (int i = 0; i < n; ++i) cin >> R[i]; auto itr_min = min_element(R.begin(), R.end()); auto itr_max = max_element(itr_min, R.end()); cout << ((*itr_max - *itr_min) <= 0 ? -1 : (*itr_max - *itr_min)) << en...
#include "bits/stdc++.h" using namespace std; int main() { int n; cin >> n; int ans = -999999999, minv; cin >> minv; for (int i = 1; i < n; ++i) { int a; cin >> a; ans = max(ans, a - minv); minv = min(minv, a); } cout << ans << endl; // system("pause"); }
replace
7
14
7
17
0
sh: 1: pause: not found
p02258
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> using namespace std; int main() { int n; cin >> n; int r[n]; for (int i = 0; i < n; ++i) { cin >> r[i]; } int M = r[1] - r[0]; for (int i = 0; i < n - 1; ++i) { for (int j = i + 1; j < n; ++j) { M = max(M, r[j] - r[i]); } } cout << M << endl;...
#include <algorithm> #include <iostream> using namespace std; int main() { int n; cin >> n; int M = -1000000000; int m; cin >> m; for (int i = 1; i < n; ++i) { int r; cin >> r; M = max(M, r - m); m = min(m, r); } cout << M << endl; return 0; }
replace
7
16
7
15
TLE
p02258
C++
Time Limit Exceeded
#include <cstdio> int d[200000 + 2]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &d[i]); int maxv = -1000000001; //(n>=2)?d[1]-d[0]:-1; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (maxv < d[j] - d[i]) maxv = d[j] - d[i]; } } ...
#include <cstdio> int d[200000 + 2]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &d[i]); int maxv = d[1] - d[0]; // 2 <= n < 200000 int minv = d[0]; // Store a mininum value and get diff value with next value // after next mininum for (int i = 1; i < ...
replace
8
15
8
15
TLE
p02258
C++
Time Limit Exceeded
#include <algorithm> #include <cassert> #include <cmath> #include <iostream> #include <vector> typedef int TInt; typedef std::vector<TInt> TList; TList Input() { int Count; std::cin >> Count; TList List(Count); for (int i = 0; i < Count; ++i) { std::cin >> List[i]; } return List; } int main() { TList ...
#include <algorithm> #include <cassert> #include <cmath> #include <iostream> #include <vector> typedef int TInt; typedef std::vector<TInt> TList; TList Input() { int Count; std::cin >> Count; TList List(Count); for (int i = 0; i < Count; ++i) { std::cin >> List[i]; } return List; } int main() { TList ...
replace
22
24
22
24
TLE
p02258
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> using namespace std; int N, A[200000]; int solve(void) { int maxp = 1 - 1000000000; for (int i = 0; i < N - 1; i++) { for (int j = i + 1; j < N; j++) { maxp = max(maxp, A[j] - A[i]); } } return maxp; } int main(void) { cin >> N; for (int i = 0; i < N...
#include <algorithm> #include <iostream> using namespace std; int N, A[200000]; int solve(void) { auto maxp = A[1] - A[0]; auto minr = min(A[0], A[1]); for (auto i = 2; i < N; i++) { maxp = max(maxp, A[i] - minr); minr = min(minr, A[i]); } return maxp; } int main(void) { cin >> N; for (int i = ...
replace
7
12
7
12
TLE
p02258
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 200000; int main() { int R[MAX], n; cin >> n; for (int i = 0; i = n; i++) cin >> R[i]; int maxv = -2000000000; int minv = R[0]; for (int i = 1; i < n; i++) { maxv = max(maxv, R[i] - minv); minv = min(minv, R...
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 200000; int main() { int R[MAX], n; cin >> n; for (int i = 0; i < n; i++) cin >> R[i]; int maxv = -2000000000; int minv = R[0]; for (int i = 1; i < n; i++) { maxv = max(maxv, R[i] - minv); minv = min(minv, R...
replace
9
10
9
10
TLE
p02258
C++
Time Limit Exceeded
#include <iostream> #include <vector> int main() { std::vector<long> Dat = {}; int t = 0; std::cin >> t; for (int i = 0; i < t; i++) { int tmp = 0; std::cin >> tmp; Dat.push_back(tmp); } long max = *(Dat.begin() + 1) - *Dat.begin(); for (auto cur = Dat.begin(); cur != Dat.end() - 1; cur++) //...
#include <iostream> #include <vector> int main() { std::vector<long> Dat = {}; int t = 0; std::cin >> t; for (int i = 0; i < t; i++) { int tmp = 0; std::cin >> tmp; Dat.push_back(tmp); } long min = *Dat.begin(), max = -2E9; for (auto cur = Dat.begin() + 1; cur != Dat.end(); cur++) { if (*...
replace
12
23
12
18
TLE
p02258
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; long long n, a[1000000], x, y, mi, an; int main() { cin >> n; for (x = 0; x < n; x++) { cin >> a[x]; for (y = x - 1; y >= 0; y--) { if (x == 1) { mi = a[x]; } if (a[x] < mi) { mi = a[x]; } if (x == 1 && y == 0) { ...
#include <bits/stdc++.h> using namespace std; long long n, a[1000000], x, y, mi, an; int main() { cin >> n; for (x = 0; x < n; x++) { cin >> a[x]; if (x == 1) { an = a[x] - a[x - 1]; } if (x == 0) { mi = a[x]; } if (an < a[x] - mi) { an = a[x] - mi; } if (mi > a[x])...
replace
7
20
7
18
TLE
p02258
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int n; cin >> n; int *r; r = new int[n]; if (r == NULL) { cout << "Error!" << endl; return -1; } int i, j; for (i = 0; i < n; i++) { cin >> r[i]; } int max = r[1] - r[0]; for (i = 0; i < n; i++) { for (j = i + 1; j < n; j++) {...
#include <iostream> using namespace std; int main() { int n; cin >> n; int *r; r = new int[n]; if (r == NULL) { cout << "Error!" << endl; return -1; } int i, j; for (i = 0; i < n; i++) { cin >> r[i]; } int max = r[1] - r[0]; for (j = n - 1; j >= 0; j--) { if (r[j] <= max) c...
replace
18
20
18
22
TLE
p02258
C++
Time Limit Exceeded
#include <algorithm> #include <iomanip> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<double> r(n); for (int i = 0; i < n; i++) { cin >> r[i]; } double max_profit = -1000000000; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { ...
#include <algorithm> #include <iomanip> #include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<double> r(n); for (int i = 0; i < n; i++) { cin >> r[i]; } double max_profit = -1000000000; double min_r = r[0]; for (int i = 1; i < n; i++) { min_r = min(min...
replace
15
19
15
19
TLE
p02258
C++
Time Limit Exceeded
#include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include ...
#include <algorithm> #include <bitset> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include ...
replace
34
38
34
38
TLE
p02258
C++
Time Limit Exceeded
#include <iostream> using namespace std; class MaximumProfit { public: int solve(int n, int *r); }; int MaximumProfit::solve(int n, int *r) { int maxp = -2000000000; for (int i = 0; i < n - 1; i++) for (int j = i + 1; j < n; j++) { if ((r[j] - r[i]) > maxp) maxp = r[j] - r[i]; } return...
#include <iostream> using namespace std; class MaximumProfit { public: int solve(int n, int *r); }; int MaximumProfit::solve(int n, int *r) { int maxp = -2000000000; int minr = r[0]; for (int i = 1; i < n; i++) { if ((r[i] - minr) > maxp) maxp = r[i] - minr; if (r[i] < minr) minr = r[i]; ...
replace
11
16
11
18
TLE
p02258
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int n; cin >> n; int m[200000]; for (int i = 0; i < n; i++) { cin >> m[i]; } int max = m[1] - m[0]; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { if (max < m[j] - m[i]) max = m[j] - m[i]; } } cout <...
#include <iostream> using namespace std; int main() { int n; cin >> n; int m[200000]; for (int i = 0; i < n; i++) { cin >> m[i]; } int max = -1000000000, min = m[0]; for (int i = 1; i < n; i++) { if (max < m[i] - min) max = m[i] - min; if (m[i] < min) min = m[i]; } cout << ma...
replace
11
17
11
17
TLE
p02258
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n, a[200001] = {}; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int max = a[1] - a[0]; for (int i = 1; i < n; i++) for (int j = 0; j < i; j++) if (a[i] - a[j] > max) max = a[i] - a[j]; cout << max << endl; return 0;...
#include <bits/stdc++.h> using namespace std; int main() { int n, a[200001] = {}; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int max = a[1] - a[0]; int min = a[0]; for (int i = 1; i < n; i++) { if (a[i] - min > max) max = a[i] - min; if (min > a[i]) min = a[i]; } cout << ...
replace
8
12
8
15
TLE
p02258
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n, tmp; cin >> n; vector<int> rt(n); for (int i = 0; i < n; i++) { cin >> rt[i]; } int ans = INT_MIN; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i < j) { tmp = rt[j] - rt[i]; if (ans < tmp) ...
#include <bits/stdc++.h> using namespace std; int main() { int n, tmp; cin >> n; vector<int> rt(n); for (int i = 0; i < n; i++) { cin >> rt[i]; } int ans = INT_MIN; int minv = rt[0]; for (int j = 1; j < n; j++) { ans = (ans >= rt[j] - minv) ? ans : rt[j] - minv; minv = (minv <= rt[j]) ? min...
replace
11
19
11
15
TLE
p02258
Python
Runtime Error
import sys values = [int(input()) for i in range(int(input()))] maxv = -sys.maxsize - 1 minv = values[0] for val in enumerate(values): if maxv < (val - minv): maxv = val - minv if minv > val: minv = val print(maxv)
n = int(input()) R = [int(input()) for _ in range(n)] minv, maxv = R[0], R[1] - R[0] for j in range(1, n): maxv = max(maxv, R[j] - minv) minv = min(minv, R[j]) print(maxv)
replace
0
11
0
6
TypeError: unsupported operand type(s) for -: 'tuple' and 'int'
Traceback (most recent call last): File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02258/Python/s112466969.py", line 8, in <module> if maxv < (val - minv): TypeError: unsupported operand type(s) for -: 'tuple' and 'int'
p02258
C++
Runtime Error
#include <stdio.h> int main(void) { int i = 0; int n = 0; int min; int now; int max_margin = -2147483648; int margin; scanf("%d", &n); scanf("%d", &min); for (i = 1; i < n; i++) { scanf("%d", now); margin = now - min; if (margin > max_margin) { max_margin = margin; } if (no...
#include <stdio.h> int main(void) { int i = 0; int n = 0; int min; int now; int max_margin = -2147483648; int margin; scanf("%d", &n); scanf("%d", &min); for (i = 1; i < n; i++) { scanf("%d", &now); margin = now - min; if (margin > max_margin) { max_margin = margin; } if (n...
replace
13
14
13
14
-11
p02258
C++
Time Limit Exceeded
#include <iostream> #include <vector> using namespace std; int timeSerialDiff(vector<int> &v) { int size = v.size(), i, j, max, cnt = 0; for (i = 0; i < size; i++) { int start = v[i]; for (j = i + 1; j < size; j++) { int diff = v[j] - v[i]; max = (cnt == 0 || max < diff) ? diff : max; cnt...
#include <iostream> #include <vector> using namespace std; int timeSerialDiff(vector<int> &v) { int size = v.size(); if (size < 2) { return 0; } int i, max, min, cnt = 0; min = v[0]; max = v[1] - v[0]; for (i = 1; i < size; i++) { int diff = v[i] - min; max = max < diff ? diff : max; min ...
replace
5
13
5
16
TLE
p02258
C++
Time Limit Exceeded
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <list> #include <map> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> r; for (int i = 0; i < n; i++) { int ri; cin >> ri; r.push_back(ri); } int diffmax = ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <iostream> #include <list> #include <map> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> r; for (int i = 0; i < n; i++) { int ri; cin >> ri; r.push_back(ri); } int diffmax = ...
replace
23
27
23
27
TLE
p02258
C++
Time Limit Exceeded
#include <bits/stdc++.h> #define pout(n) printf("%d\n", n) #define rep(i, a, n) for (int i = a; i < n; i++) #define per(i, n, a) for (int i = n - 1; i >= a; i--) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); const int d4x[4] = {1, 0, -1, 0}; const int d4y[4] = {0, 1, 0, -1}; const int...
#include <bits/stdc++.h> #define pout(n) printf("%d\n", n) #define rep(i, a, n) for (int i = a; i < n; i++) #define per(i, n, a) for (int i = n - 1; i >= a; i--) #define SORT(v, n) sort(v, v + n); #define VSORT(v) sort(v.begin(), v.end()); const int d4x[4] = {1, 0, -1, 0}; const int d4y[4] = {0, 1, 0, -1}; const int...
replace
26
28
26
30
TLE
p02258
C++
Runtime Error
#include <algorithm> #include <iostream> using namespace std; const int NMAX = 20000; int maximum_profit(int *r, int n) { int mini = r[0]; int maxi = r[1] - r[0]; for (int i = 1; i < n; i++) { maxi = max(maxi, r[i] - mini); mini = min(mini, r[i]); } return maxi; } int main(void) { int *r; r = n...
#include <algorithm> #include <iostream> using namespace std; const int NMAX = 2000000; int maximum_profit(int *r, int n) { int mini = r[0]; int maxi = r[1] - r[0]; for (int i = 1; i < n; i++) { maxi = max(maxi, r[i] - mini); mini = min(mini, r[i]); } return maxi; } int main(void) { int *r; r =...
replace
3
4
3
4
0
p02258
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> using namespace std; int main() { int n; cin >> n; int *a = new int[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int m = (1 << 31); for (int i = 0; i < n; i++) { for (int j = i - 1; j >= 0; j--) { m = max(a[i] - a[j], m); } } cout << m <<...
#include <algorithm> #include <iostream> using namespace std; int main() { int n; cin >> n; int *a = new int[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int m = (1 << 31); int minx = a[0]; for (int i = 1; i < n; i++) { m = max(m, a[i] - minx); minx = min(minx, a[i]); } cout << m <<...
replace
12
16
12
16
TLE
p02258
C++
Time Limit Exceeded
#include <iostream> using namespace std; int functione(int num[], int N); int main() { int n; cin >> n; int *num = new int[n]; for (int i = 0; i < n; i++) cin >> num[i]; cout << functione(num, n) << endl; return 0; } int functione(int num[], int N) { int profit = -2000000000; for (int i = 0; i ...
#include <iostream> using namespace std; int functione(int num[], int N); int main() { int n; cin >> n; int *num = new int[n]; for (int i = 0; i < n; i++) cin >> num[i]; cout << functione(num, n) << endl; return 0; } int functione(int num[], int N) { int max = -2000000000; int min = num[0]; f...
replace
18
25
18
27
TLE
p02258
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main(void) { int n; cin >> n; vector<int> prices(n); for (int i = 0; i < n; i++) { cin >> prices[i]; } int mprofit = -1000000000; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { mprofit = m...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main(void) { int n; cin >> n; vector<int> prices(n); for (int i = 0; i < n; i++) { cin >> prices[i]; } int mprofit = -1111111111; int minv = prices[0]; for (int i = 1; i < n; i++) { mprofit = max(mprofit, pric...
replace
14
19
14
19
TLE
p02258
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; vector<int> r(n); for (int i = 0; i < n; ++i) { cin >> r[i]; } int ans = -1000000007; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { ans = max(ans, r[j] - r[i]); } } cout << ans << endl;...
#include <bits/stdc++.h> using namespace std; int main(void) { int n; cin >> n; vector<int> r(n); for (int i = 0; i < n; ++i) { cin >> r[i]; } int ans = -1000000007; int minv = r[0]; for (int i = 1; i < n; ++i) { ans = max(ans, r[i] - minv); minv = min(minv, r[i]); } cout << ans << endl...
replace
11
15
11
15
TLE
p02258
C++
Runtime Error
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 20000; int main() { int n; int minv; int maxv = -2000000000; int R[MAX]; cin >> n; for (int i = 0; i < n; i++) { cin >> R[i]; } minv = R[0]; for (int j = 1; j < n; j++) { maxv = max(maxv, R[j] - minv); m...
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 200000; int main() { int n; int minv; int maxv = -2000000000; int R[MAX]; cin >> n; for (int i = 0; i < n; i++) { cin >> R[i]; } minv = R[0]; for (int j = 1; j < n; j++) { maxv = max(maxv, R[j] - minv); ...
replace
3
4
3
4
0
p02258
C++
Time Limit Exceeded
#include <algorithm> #include <cstdio> using namespace std; const int MAX_VALUE = 200000; int R[MAX_VALUE]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &R[i]); int max_income = -1000000001; for (int i = 0; i < n - 1; i++) for (int j = i + 1; j < n; j++) max_i...
#include <algorithm> #include <cstdio> using namespace std; const int MAX_VALUE = 200000; int R[MAX_VALUE]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &R[i]); int min_val = R[0]; int max_val = -1000000001; for (int j = 1; j < n; j++) { max_val = max(max_val, R[j...
replace
14
20
14
21
TLE
p02258
C++
Runtime Error
#include <limits.h> #include <stdio.h> int main(void) { int n, i, tmp, tmp2; int profit = INT_MIN; int min = INT_MAX; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &tmp); tmp2 = tmp - min; if (tmp2 > profit) { profit = tmp2; } if (tmp < min) min = tmp; } return pr...
#include <limits.h> #include <stdio.h> int main(void) { int n, i, tmp, tmp2; int profit = INT_MIN; int min = INT_MAX; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &tmp); tmp2 = tmp - min; if (tmp2 > profit) { profit = tmp2; } if (tmp < min) min = tmp; } printf("%...
replace
17
18
17
19
3
p02258
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) for (int i = 0; i < (n); ++i) #define SORT(c) sort((c).begin(), (c).end()) const double EPS = 1e-10; // sample:if((double)>=(double)+EPS) #define CLR(a) memset((&a), 0, sizeof(a)) // clea...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) for (int i = 0; i < (n); ++i) #define SORT(c) sort((c).begin(), (c).end()) const double EPS = 1e-10; // sample:if((double)>=(double)+EPS) #define CLR(a) memset((&a), 0, sizeof(a)) // clea...
replace
23
28
23
27
TLE
p02258
C++
Runtime Error
// // Created by sanyinchen on 17/4/17. // #include <cstdio> #include <iostream> #include <limits> #include <string.h> #include <vector> using namespace std; vector<int> findMaxWithMidPoint(int *array, int low, int high) { int mid = (low + high) / 2; int leftSum = 0, leftLow = mid; int rightSum = 0, rightHigh...
// // Created by sanyinchen on 17/4/17. // #include <cstdio> #include <iostream> #include <limits> #include <string.h> #include <vector> using namespace std; vector<int> findMaxWithMidPoint(int *array, int low, int high) { int mid = (low + high) / 2; int leftSum = 0, leftLow = mid; int rightSum = 0, rightHigh...
replace
78
79
78
79
-11
p02258
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int maxval = -1000000000; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { maxval = max(maxval, a[j] - a[i]); } } cout << maxval ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i]; int maxval = -1000000000; int minval = a[0]; for (int i = 1; i < n; i++) { maxval = max(maxval, a[i] - minval); minval = min(minval, a[i]); } cout << ma...
replace
11
15
11
15
TLE
p02258
C++
Time Limit Exceeded
#include <iostream> using namespace std; int main() { int n, x[1000000]; cin >> n; for (int i = 0; i < n; i++) { cin >> x[i]; } int max = x[1] - x[0]; for (int k = 0; k < n; k++) { for (int m = k + 1; m < n; m++) { if (max < (x[m] - x[k])) max = x[m] - x[k]; } } cout << max <<...
#include <iostream> using namespace std; int main() { int n, x[1000000]; cin >> n; for (int i = 0; i < n; i++) { cin >> x[i]; } int max = x[1] - x[0]; int min = x[0]; for (int k = 1; k < n; k++) { if (max < (x[k] - min)) max = (x[k] - min); if (min > x[k]) min = x[k]; } cout <...
replace
10
15
10
16
TLE
p02258
C++
Time Limit Exceeded
#include <bits/stdc++.h> using namespace std; long long MaxProfit(int n, long long *Rt) { long long max = LLONG_MIN; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { long long tmp = Rt[j] - Rt[i]; if (max < tmp) max = tmp; } } return max; } int main() { int n; c...
#include <bits/stdc++.h> using namespace std; long long MaxProfit(int n, long long *Rt) { long long max = LLONG_MIN; long long MinRt = Rt[0]; for (int j = 1; j < n; j++) { long long tmp = Rt[j] - MinRt; if (max < tmp) max = tmp; if (MinRt > Rt[j]) MinRt = Rt[j]; } return max; } int m...
replace
5
11
5
12
TLE
p02258
C++
Runtime Error
#include <iostream> using namespace std; static const int MAX = 20000; int main() { int R[MAX], n; cin >> n; for (int i = 0; i < n; i++) { cin >> R[i]; } int maxv = -2000000000; int minv = R[0]; for (int j = 1; j < n; j++) { maxv = max(maxv, R[j] - minv); minv = min(minv, R[j]); } cout...
#include <iostream> using namespace std; static const int MAX = 200000; int main() { int R[MAX], n; cin >> n; for (int i = 0; i < n; i++) { cin >> R[i]; } int maxv = -2000000000; int minv = R[0]; for (int j = 1; j < n; j++) { maxv = max(maxv, R[j] - minv); minv = min(minv, R[j]); } cou...
replace
2
3
2
3
0
p02258
C++
Runtime Error
#include <iostream> using namespace std; int R[2000]; int num; int main() { // cout << "????????\???????????¶??´??????" << endl; cin >> num; for (int i = 0; i < num; i++) { cin >> R[i]; } int maxv = -2000000000; int minv = R[0]; for (int j = 1; j < num; j++) { if (maxv < R[j] - minv) { maxv ...
#include <iostream> using namespace std; int R[200000]; int num; int main() { // cout << "????????\???????????¶??´??????" << endl; cin >> num; for (int i = 0; i < num; i++) { cin >> R[i]; } int maxv = -2000000000; int minv = R[0]; for (int j = 1; j < num; j++) { if (maxv < R[j] - minv) { max...
replace
2
3
2
3
0
p02258
C++
Time Limit Exceeded
#include <algorithm> #include <iostream> using namespace std; int n; const int MAX_N = 200000; int R[MAX_N]; int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> R[i]; } int maxv = -2000000000; for (int j = 1; j <= n - 1; j++) { for (int i = 0; i <= j - 1; i++) { maxv = max(maxv, R[j]...
#include <algorithm> #include <iostream> using namespace std; int n; const int MAX_N = 200000; int R[MAX_N]; int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> R[i]; } int maxv = -2000000000; int minv = R[0]; for (int j = 1; j < n; j++) { maxv = max(maxv, R[j] - minv); minv = min(m...
replace
16
20
16
21
TLE
p02258
C++
Runtime Error
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 20000; int main() { int R[MAX], n; cin >> n; for (int i = 0; i < n; i++) cin >> R[i]; int maxv = -2000000000; int minv = R[0]; for (int i = 1; i < n; i++) { maxv = max(maxv, R[i] - minv); minv = min(minv, R[...
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 200000; int main() { int R[MAX], n; cin >> n; for (int i = 0; i < n; i++) cin >> R[i]; int maxv = -2000000000; int minv = R[0]; for (int i = 1; i < n; i++) { maxv = max(maxv, R[i] - minv); minv = min(minv, R...
replace
3
4
3
4
0
p02258
C++
Time Limit Exceeded
#include <iostream> int main() { int n; int r[200000]; std::cin >> n; for (int i = 0; i < n; i++) { std::cin >> r[i]; } int s = r[1] - r[0]; for (int i = 0; i < n - 1; i++) { for (int j = i + 1; j < n; j++) { int ss = r[j] - r[i]; if (ss > s) { s = ss; } } } std:...
#include <iostream> int main() { int n; int r[200000]; std::cin >> n; for (int i = 0; i < n; i++) { std::cin >> r[i]; } int s = r[1] - r[0]; int rr = r[0]; for (int i = 1; i < n; i++) { if (r[i] - rr > s) { s = r[i] - rr; } if (r[i] < rr) { rr = r[i]; } } std::cout <...
replace
10
16
10
17
TLE
p02258
C++
Time Limit Exceeded
#include <cmath> #include <iostream> #include <vector> using namespace std; int main() { long long n, MAX = -1000000000; cin >> n; vector<int> R(n); /* 株価の値を入力 */ for (int i = 0; i < n; i++) { cin >> R[i]; } /* 株価の最大値を探す */ for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { ...
#include <cmath> #include <iostream> #include <vector> using namespace std; int main() { long long n, MAX = -1000000000; cin >> n; vector<int> R(n); /* 株価の値を入力 */ for (int i = 0; i < n; i++) { cin >> R[i]; } /* 株価の最大値を探す */ for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { ...
insert
21
21
21
23
TLE
p02258
C++
Runtime Error
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 20000; int main() { int R[MAX], N; cin >> N; for (int i = 0; i < N; i++) cin >> R[i]; int maxv = R[1] - R[0]; int minv = R[0]; for (int i = 1; i < N; i++) { maxv = max(maxv, R[i] - minv); minv = min(minv, R[i...
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 200000; int main() { int R[MAX], N; cin >> N; for (int i = 0; i < N; i++) cin >> R[i]; int maxv = R[1] - R[0]; int minv = R[0]; for (int i = 1; i < N; i++) { maxv = max(maxv, R[i] - minv); minv = min(minv, R[...
replace
3
4
3
4
0
p02258
C++
Runtime Error
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 20000; int main() { int R[MAX], n; cin >> n; for (int i = 0; i < n; i++) cin >> R[i]; int maxv = -2000000000; int minv = R[0]; for (int i = 1; i < n; i++) { maxv = max(maxv, R[i] - minv); minv = min(minv, R[i]);...
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 200000; int main() { int R[MAX], n; cin >> n; for (int i = 0; i < n; i++) cin >> R[i]; int maxv = -2000000000; int minv = R[0]; for (int i = 1; i < n; i++) { maxv = max(maxv, R[i] - minv); minv = min(minv, R[i])...
replace
3
4
3
4
0
p02258
Python
Time Limit Exceeded
N = int(input()) R = [int(input()) for i in range(N)] sa = R[N - 1] - R[N - 2] for i in reversed(range(N)): for j in reversed(range(i)): tmp = R[i] - R[j] if tmp > sa: sa = tmp print(sa)
N = int(input()) R = [int(input()) for i in range(N)] min_v = R[0] max_v = R[1] - R[0] for i in range(1, len(R)): if min_v > R[i - 1]: min_v = R[i - 1] if max_v < R[i] - min_v: max_v = R[i] - min_v print(max_v)
replace
3
10
3
11
TLE
p02258
C++
Time Limit Exceeded
#include <algorithm> #include <assert.h> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <typeinfo> #include <...
#include <algorithm> #include <assert.h> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <typeinfo> #include <...
replace
35
43
35
38
TLE
p02259
C++
Runtime Error
#include <iostream> using namespace std; int bubbleSort(int A[], int N) { int sw = 0; bool flag = 1; for (int i = 0; flag; i++) { flag = 0; for (int j = N - 1; j >= i + 1; j++) { if (A[j] < A[j - 1]) { swap(A[j], A[j - 1]); flag = 1; sw++; } } } return sw; } i...
#include <iostream> using namespace std; int bubbleSort(int A[], int N) { int sw = 0; bool flag = 1; for (int i = 0; flag; i++) { flag = 0; for (int j = N - 1; j >= i + 1; j--) { if (A[j] < A[j - 1]) { swap(A[j], A[j - 1]); flag = 1; sw++; } } } return sw; } i...
replace
8
9
8
9
-11
p02259
C++
Time Limit Exceeded
// bubble sort #include <iostream> #include <math.h> using namespace std; int main() { int n, d, i1, i2, times; cin >> n; int a[n]; for (i1 = 0; i1 < n; i1++) { cin >> a[i1]; } times = 0; i2 = n; for (i2 = n; i2 > 0; i2--) { i1 = n; while (1) { i1--; if (a[i1] < a[i1 - 1]) { ...
// bubble sort #include <iostream> #include <math.h> using namespace std; int main() { int n, d, i1, i2, times; cin >> n; int a[n]; for (i1 = 0; i1 < n; i1++) { cin >> a[i1]; } times = 0; i2 = n; for (i2 = n; i2 > 0; i2--) { i1 = n; while (1) { i1--; if (a[i1] < a[i1 - 1]) { ...
replace
35
36
35
41
TLE
p02259
C++
Runtime Error
#include <iostream> using namespace std; int bubbleSort(int p[], int n) { int flag = 1; int count = 0; for (int i = 0; i < n - 1; i++) { if (!flag) break; flag = 0; for (int j = n - 1; j > i; j++) if (p[j] < p[j - 1]) { flag = 1; int t = p[j]; p[j] = p[j - 1]; ...
#include <iostream> using namespace std; int bubbleSort(int p[], int n) { int flag = 1; int count = 0; for (int i = 0; i < n - 1; i++) { if (!flag) break; flag = 0; for (int j = n - 1; j > i; j--) if (p[j] < p[j - 1]) { flag = 1; int t = p[j]; p[j] = p[j - 1]; ...
replace
9
10
9
10
-11
p02259
C++
Runtime Error
#include <iostream> #include <vector> using namespace std; int main() { int n; vector<int> List; int count = 0; cin >> n; for (int i = 0; i < n; i++) { int Value; cin >> Value; List.push_back(Value); } bool Flag = true; while (Flag) { Flag = false; for (int j = n - 1; j > 0; j++...
#include <iostream> #include <vector> using namespace std; int main() { int n; vector<int> List; int count = 0; cin >> n; for (int i = 0; i < n; i++) { int Value; cin >> Value; List.push_back(Value); } bool Flag = true; while (Flag) { Flag = false; for (int j = n - 1; j > 0; j--...
replace
21
22
21
22
-11
p02259
C++
Runtime Error
#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" // #include "libs.h" #include <random> #include <unordered_map> #include <unordered_set> // #include <opencv2/core.hpp> // #include <opencv2/highgui.hpp> // #include <opencv2/imgproc.hpp> using namespace std; // 呪文 #define DUMPOUT cerr #define dump(...) ...
#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" // #include "libs.h" #include <random> #include <unordered_map> #include <unordered_set> // #include <opencv2/core.hpp> // #include <opencv2/highgui.hpp> // #include <opencv2/imgproc.hpp> using namespace std; // 呪文 #define DUMPOUT cerr #define dump(...) ...
replace
178
179
178
179
0
1 2 3 4 5
p02259
C++
Runtime Error
#include <iostream> using namespace std; int main() { int n, a[100], ans = 0; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { for (int j = n - 1; j >= i + 1; j++) { if (a[i] > a[j]) swap(a[i], a[j]); ans++; } } for (int i = 0; i < n; i++) { ...
#include <iostream> using namespace std; int main() { int n, a[100], ans = 0; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) { for (int j = n - 1; j >= i + 1; j--) { if (a[j] < a[j - 1]) { swap(a[j], a[j - 1]); ans++; } } } for (int i =...
replace
8
12
8
13
-11
p02259
C++
Runtime Error
#include <bits/stdc++.h> using namespace std; int main() { int n; int a[100]; cin >> n; int k = 0, count = 0; for (int i = 0; i < n; i++) cin >> a[i]; while (1) { for (int i = n - 1; i > 0 + k; i--) { if (a[i - 1] > a[i]) { swap(a[i - 1], a[i]); count++; } } k++; ...
#include <bits/stdc++.h> using namespace std; int main() { int n; int a[100]; cin >> n; int k = 0, count = 0; for (int i = 0; i < n; i++) cin >> a[i]; while (1) { for (int i = n - 1; i > 0 + k; i--) { if (a[i - 1] > a[i]) { swap(a[i - 1], a[i]); count++; } } k++; ...
replace
17
18
17
18
0
p02259
C++
Time Limit Exceeded
#include <fstream> #include <iostream> #include <vector> using namespace std; void print_vector(vector<int> &v) { for (int x : v) { std::cout << x << " "; } std::cout << endl; } int main() { #ifdef LOCAL // ??\??? cin ?????\????????? 'xxx.txt' ????????? std::ifstream in("alds1_2_a.txt"); std::cin.rdbu...
#include <fstream> #include <iostream> #include <vector> using namespace std; void print_vector(vector<int> &v) { for (vector<int>::iterator it = v.begin(); it != v.end(); it++) { std::cout << *it; if (it != v.end() - 1) { std::cout << " "; } } std::cout << endl; } int main() { #ifdef LOCAL ...
replace
6
8
6
11
TLE
p02259
C++
Runtime Error
#include <iostream> using namespace std; int bubbleSort(int A[], int N) { int sw = 0; bool flag = 1; for (int i = 0; flag; i++) { for (int j = N - 1; j >= i + 1; j--) { if (A[j] < A[j - 1]) { swap(A[j], A[j - 1]); flag = 1; sw++; } } } return sw; } int main() { ...
#include <iostream> using namespace std; int bubbleSort(int A[], int N) { int sw = 0; bool flag = 1; for (int i = 0; flag; i++) { flag = 0; for (int j = N - 1; j >= i + 1; j--) { if (A[j] < A[j - 1]) { swap(A[j], A[j - 1]); flag = 1; sw++; } } } return sw; } i...
insert
7
7
7
8
TLE
p02259
C++
Runtime Error
/*** * ?????????????????? * ???????????????????????£???????????£??\????´?????????????????????§????¬???????????????°????????? * ?????????????°?????????£??\??????????´?????????????????????????????????§?°???¢?????????????????°??????????????? ****/ #include <iostream> #include <vector> using namespace std; int main(v...
/*** * ?????????????????? * ???????????????????????£???????????£??\????´?????????????????????§????¬???????????????°????????? * ?????????????°?????????£??\??????????´?????????????????????????????????§?°???¢?????????????????°??????????????? ****/ #include <iostream> #include <vector> using namespace std; int main(v...
replace
26
28
26
27
-11
p02259
C++
Time Limit Exceeded
#include <cstdio> using namespace std; void b_sort(int *a, int N); int main() { int a[100]; int N; scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%d", &a[i]); } b_sort(a, N); } void b_sort(int *a, int N) { int j = N - 1; int t; int count = 0; while (1) { for (int i = 0; i < j; i+...
#include <cstdio> using namespace std; void b_sort(int *a, int N); int main() { int a[100]; int N; scanf("%d", &N); for (int i = 0; i < N; i++) { scanf("%d", &a[i]); } b_sort(a, N); } void b_sort(int *a, int N) { int j = N - 1; int t; int count = 0; while (1) { for (int i = 0; i < j; i+...
replace
30
31
30
32
TLE
p02260
C++
Runtime Error
#include <stdio.h> int selectionSort(int A[], int N) { int i, j, t, sw = 0, minj; for (i = 0; i < N - 1; i++) { minj = i; for (j = i; j < N; j++) { if (A[j] < A[minj]) minj = j; } t = A[minj]; A[minj] = A[i]; A[i] = t; if (i != minj) sw++; } return sw; } int mai...
#include <stdio.h> int selectionSort(int A[], int N) { int i, j, t, sw = 0, minj; for (i = 0; i < N - 1; i++) { minj = i; for (j = i; j < N; j++) { if (A[j] < A[minj]) minj = j; } t = A[minj]; A[minj] = A[i]; A[i] = t; if (i != minj) sw++; } return sw; } int mai...
replace
24
25
24
25
-11
p02260
C++
Time Limit Exceeded
#include <iostream> using namespace std; // ?????????????????????????????????????????° int selectionSort(int A[], int N) { int sw = 0; for (int i = 0; i < N; i++) { int minj = i; for (int j = i; i < N; j++) { if (A[j] < A[minj]) minj = j; } if (i != minj) { swap(A[i], A[minj]); ...
#include <iostream> using namespace std; // ?????????????????????????????????????????° int selectionSort(int A[], int N) { int sw = 0; for (int i = 0; i < N; i++) { int minj = i; for (int j = i; j < N; j++) { if (A[j] < A[minj]) minj = j; } if (i != minj) { swap(A[i], A[minj]); ...
replace
8
9
8
9
TLE
p02260
C++
Runtime Error
#include <stdio.h> int main() { int m, min, minn, i, j, n, c; int a[100]; c = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a[i]); } for (i = 0; i < n - 1; i++) { m = a[i]; min = a[i]; for (j = i + 1; j < n; j++) { if (min > a[j]) { min = a[j]; minn = j;...
#include <stdio.h> int main() { int m, min, minn, i, j, n, c; int a[100]; c = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a[i]); } for (i = 0; i < n - 1; i++) { m = a[i]; min = a[i]; minn = i; for (j = i + 1; j < n; j++) { if (min > a[j]) { min = a[j]; ...
insert
13
13
13
14
0
p02261
C++
Runtime Error
#include <iostream> using namespace std; struct Card { char suit, value; }; void bubble(struct Card A[], int N) { for (int i = 0; i < N; i++) { for (int j = N - 1; j < i + 1; j--) { if (A[j].value < A[j - 1].value) { Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t; } } }...
#include <iostream> using namespace std; struct Card { char suit, value; }; void bubble(struct Card A[], int N) { for (int i = 0; i < N; i++) { for (int j = N - 1; j >= i + 1; j--) { if (A[j].value < A[j - 1].value) { Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t; } } ...
replace
9
10
9
10
-11
p02261
C++
Runtime Error
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; typedef vector<string> card_list; bool comp(string a, string b) { int x = static_cast<int>(a[1]) - 48; int y = static_cast<int>(b[1]) - 48; return x < y; } int bubbleSort(card_list &A) { int N = A.size(); int...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; typedef vector<string> card_list; bool comp(string a, string b) { int x = static_cast<int>(a[1]) - 48; int y = static_cast<int>(b[1]) - 48; return x < y; } int bubbleSort(card_list &A) { int N = A.size(); int...
replace
74
75
74
75
0
p02261
C++
Runtime Error
#include <iostream> using namespace std; void selectionSort(); void bubbleSort(); struct card { int value; char mark; }; void write(card[]); bool isStable(card[]); int n; card c[40], c1[40], c2[40]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> c[i].mark >> c[i].value; } for (int i = 0;...
#include <iostream> using namespace std; void selectionSort(); void bubbleSort(); struct card { int value; char mark; }; void write(card[]); bool isStable(card[]); int n; card c[40], c1[40], c2[40]; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> c[i].mark >> c[i].value; } for (int i = 0;...
replace
89
90
89
90
0
i:2 j:3 k:0
p02261
C++
Runtime Error
#include <algorithm> #include <iostream> #include <string> using namespace std; int n; string a[36], b[36]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i], b[i] = a[i]; for (int i = 0; i < n; i++) { for (int j = n - 1; j > i; j++) { if (b[i][1] > b[j][1]) swap(b[i], b[j]); ...
#include <algorithm> #include <iostream> #include <string> using namespace std; int n; string a[36], b[36]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i], b[i] = a[i]; for (int i = 0; i < n; i++) { for (int j = n - 1; j > i; j--) { if (b[j - 1][1] > b[j][1]) swap(b[j - 1], b...
replace
11
14
11
14
-11
p02261
C++
Runtime Error
#include "bits/stdc++.h" using namespace std; string bubbleSort(vector<char> &Mb, vector<int> &Nb, int A); string selectionSort(vector<char> &Ms, vector<int> &Ns, int A); int main(void) { int A; cin >> A; vector<char> M(A), Mb(A), Ms(A); vector<int> N(A), Nb(A), Ns(A); for (int i = 0; i < A; i++) cin ...
#include "bits/stdc++.h" using namespace std; string bubbleSort(vector<char> &Mb, vector<int> &Nb, int A); string selectionSort(vector<char> &Ms, vector<int> &Ns, int A); int main(void) { int A; cin >> A; vector<char> M(A), Mb(A), Ms(A); vector<int> N(A), Nb(A), Ns(A); for (int i = 0; i < A; i++) cin ...
replace
90
91
90
91
0
p02261
C++
Runtime Error
#include <cstdint> #include <fstream> #include <iostream> #include <string> typedef std::uint_least16_t USI; typedef std::int_least16_t SSI; typedef std::uint_least32_t ULI; // 10^9 typedef std::int_least32_t SLI; typedef std::uint_least64_t ULLI; typedef std::int_least64_t SLLI; using namespace std; struct Card { ...
#include <cstdint> #include <fstream> #include <iostream> #include <string> typedef std::uint_least16_t USI; typedef std::int_least16_t SSI; typedef std::uint_least32_t ULI; // 10^9 typedef std::int_least32_t SLI; typedef std::uint_least64_t ULLI; typedef std::int_least64_t SLLI; using namespace std; struct Card { ...
delete
108
112
108
108
0
p02261
C++
Runtime Error
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long unsigned int ...
#include <algorithm> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <deque> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; typedef long long unsigned int ...
replace
82
84
82
84
0
p02261
C++
Runtime Error
#include <iostream> #include <string> #include <vector> #include <cstdlib> using namespace std; vector<pair<char, int>> B; vector<pair<char, int>> SelectionSort(vector<pair<char, int>> v) { for (int i = 0; i < v.size(); i++) { int mini = i; for (int j = i; j < v.size(); j++) { if (v[j].second < v[mi...
#include <iostream> #include <string> #include <vector> #include <cstdlib> using namespace std; vector<pair<char, int>> B; vector<pair<char, int>> SelectionSort(vector<pair<char, int>> v) { for (int i = 0; i < v.size(); i++) { int mini = i; for (int j = i; j < v.size(); j++) { if (v[j].second < v[mi...
replace
31
32
31
32
-6
munmap_chunk(): invalid pointer
p02261
C++
Runtime Error
#include <iostream> using namespace std; struct Card { char suit, value; }; void bubble(struct Card a[], int n) { Card hoge; for (int i = 0; i < n; i++) { for (int j = n - 1; j > i; j++) { if (a[j].value < a[j - 1].value) { hoge = a[j]; a[j] = a[j - 1]; a[j - 1] = hoge; }...
#include <iostream> using namespace std; struct Card { char suit, value; }; void bubble(struct Card a[], int n) { Card hoge; for (int i = 0; i < n; i++) { for (int j = n - 1; j > i; j--) { if (a[j].value < a[j - 1].value) { hoge = a[j]; a[j] = a[j - 1]; a[j - 1] = hoge; }...
replace
10
11
10
11
-11
p02261
C++
Runtime Error
#include <algorithm> #include <iostream> #include <stdio.h> using namespace std; struct Card { char suit, value; }; void BubbleSort(struct Card C[], int n) { Card tmp; for (int i = 0; i < n; i++) { for (int j = n - 1; j >= i; j--) { if (C[j].value > C[j - 1].value) { tmp = C[j]; C[j] = ...
#include <algorithm> #include <iostream> #include <stdio.h> using namespace std; struct Card { char suit, value; }; void BubbleSort(struct Card C[], int n) { Card tmp; for (int i = 0; i < n; i++) { for (int j = n - 1; j >= i; j--) { if (C[j].value < C[j - 1].value) { tmp = C[j]; C[j] = ...
replace
12
13
12
13
0
p02261
C++
Runtime Error
#include <iostream> using namespace std; typedef struct { char suit; char value; } Card; void bubbleSort(Card A[], int N) { for (int i = 0; i < N; i++) { for (int j = N - 1; j >= i; j--) { if (A[j].value >= A[j - 1].value) { Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t; }...
#include <iostream> using namespace std; typedef struct { char suit; char value; } Card; void bubbleSort(Card A[], int N) { for (int i = 0; i < N; i++) { for (int j = N - 1; j >= i; j--) { if (A[j].value < A[j - 1].value) { Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t; } ...
replace
11
12
11
12
0
p02262
C++
Runtime Error
#include <cmath> #include <iostream> using namespace std; #include <vector> #define ArrayNum 100 vector<int> g; int insertionSort(int a[], int n, int g) { int i, j, cnt = 0, v; for (i = g; i < n; i++) { v = a[i]; j = i - g; while (j >= 0 && a[j] > v) { a[j + g] = a[j]; j = j - g; c...
#include <cmath> #include <iostream> using namespace std; #include <vector> #define ArrayNum 1000000 vector<int> g; int insertionSort(int a[], int n, int g) { int i, j, cnt = 0, v; for (i = g; i < n; i++) { v = a[i]; j = i - g; while (j >= 0 && a[j] > v) { a[j + g] = a[j]; j = j - g; ...
replace
5
6
5
6
0
p02262
C++
Runtime Error
#include <iostream> #include <vector> using namespace std; long long cnt; int i, A[10000], n; vector<int> G; void insertionSort(int A[], int n, int g) { for (int i = g; i < n; i++) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; cnt++; } A[...
#include <iostream> #include <vector> using namespace std; long long cnt; int i, A[1000000], n; vector<int> G; void insertionSort(int A[], int n, int g) { for (int i = g; i < n; i++) { int v = A[i]; int j = i - g; while (j >= 0 && A[j] > v) { A[j + g] = A[j]; j -= g; cnt++; } ...
replace
6
7
6
7
0
p02262
C++
Runtime Error
#include <cmath> #include <iostream> #include <vector> using namespace std; int main() { long n = 0, g = 0, v = 0, cnt = 0, m = 0; cin >> n; vector<long> a(n); for (long i = 0; i < n; i++) cin >> a[i]; cnt = 0; if (n == 1) m = 1; else m = (int)(log(n) / log(3)); vector<long> G(m); f...
#include <cmath> #include <iostream> #include <vector> using namespace std; int main() { long n = 0, g = 0, v = 0, cnt = 0, m = 0; cin >> n; vector<long> a(n); for (long i = 0; i < n; i++) cin >> a[i]; cnt = 0; if (n < 3) m = 1; else m = (int)(log(n) / log(3)); vector<long> G(m); fo...
replace
16
17
16
17
0
p02262
C++
Runtime Error
#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" // #include "libs.h" #include <random> #include <unordered_map> #include <unordered_set> // #include <opencv2/core.hpp> // #include <opencv2/highgui.hpp> // #include <opencv2/imgproc.hpp> using namespace std; // 呪文 #define DUMPOUT cerr #define dump(...) ...
#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" // #include "libs.h" #include <random> #include <unordered_map> #include <unordered_set> // #include <opencv2/core.hpp> // #include <opencv2/highgui.hpp> // #include <opencv2/imgproc.hpp> using namespace std; // 呪文 #define DUMPOUT cerr #define dump(...) ...
replace
211
212
211
212
0