buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
N, K = map(int,input().split()) A = list(map(int, input().split())) OK = 10**9 NG = 1 while OK - NG > 1: ans = 0 mid = (OK+NG)//2 for a in A: ans += (a-0.1)//mid if ans > K: NG = mid else: OK = mid print(OK)
N, K = map(int,input().split()) A = list(map(int, input().split())) OK = 10**9 NG = 0 while OK - NG > 1: ans = 0 mid = (OK+NG)//2 for a in A: ans += (a-0.1)//mid if ans > K: NG = mid else: OK = mid print(OK)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
91
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PRINT(a) cout << (a) << endl #define pb push_back #define eb emplace_back #define mp make_pair #defin...
#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PRINT(a) cout << (a) << endl #define pb push_back #define eb emplace_back #define mp make_pair #defin...
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 33], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 12, 13], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25]]
1
398
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n, k; cin >> n >> k; vector<ll> a(n); for (int i = 0; i < n; i++) cin >> a[i]; ll l = 1, r = 2 * 1e9; while (r - l > 1) { ll mid = (l + r) / 2; //最大の長さをmidにできるか ll now = 0; for (int i = 0; i < n; i++) {...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ll n, k; cin >> n >> k; vector<ll> a(n); for (int i = 0; i < n; i++) cin >> a[i]; ll l = 0, r = 2 * 1e9; while (r - l > 1) { ll mid = (l + r) / 2; //最大の長さをmidにできるか ll now = 0; for (int i = 0; i < n; i++) {...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 7, 8, 9, 0, 1, 0, 34, 0, 21], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
163
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <string> using namespace std; const int MAX = 2e5 + 20; typedef long long ll; int pic[MAX], n, k; bool check(int goal) { int tem = k, i; for (i = 1; i <= n; i++) { if (pic[i] <= goal) con...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <string> using namespace std; const int MAX = 2e5 + 20; typedef long long ll; int pic[MAX], n, k; bool check(int goal) { int tem = k, i; for (i = 1; i <= n; i++) { if (pic[i] <= goal) con...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
271
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; typedef long long ll; typedef long double ld; const double E = 1e-7; const ll INF = 1e17; #define forn(i, s, f) for (int i = s; i < f; ++i) #define ft first #define sec second #define fora(i, n) for (auto i ...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; typedef long long ll; typedef long double ld; const double E = 1e-7; const ll INF = 1e17; #define forn(i, s, f) for (int i = s; i < f; ++i) #define ft first #define sec second #define fora(i, n) for (auto i ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
309
N, K = map(int, input().split()) A = list(map(int, input().split())) answer = 'Yes' score = 1 for i in range(K): score *= A[i] for i in range(N - K): next_score = score * A[K + i] // A[i] print('Yes' if next_score > score else 'No') score = next_score
N, K = map(int, input().split()) A = list(map(int, input().split())) answer = 'Yes' score = 0 for i in range(K): score += A[i] for i in range(N - K): next_score = score + A[K + i] - A[i] print('Yes' if next_score > score else 'No') score = next_score
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 0, 7, 8, 196, 0, 1, 0, 677, 17, 108], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107], ["-", 0, 1, 0, 662, 12, 657, 31, 657, 17, 48], ["+", 0, 1, 0, 662, 12, 657, 31, 657, 17, 72], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 676]...
5
97
n,k=map(int,input().split()) a=list(map(int,input().split())) for i in range(k-1): if a[k+i]>a[i]: print("Yes") else: print("No")
n,k=map(int,input().split()) a=list(map(int,input().split())) for i in range(n-k): if a[k+i]>a[i]: print("Yes") else: print("No")
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 22]]
5
70
N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range (0, N-K): if A[i] < A[K]: print('Yes') else: print('No')
N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range (0, N-K): if A[i] < A[K+i]: print('Yes') else: print('No')
[["+", 0, 57, 15, 666, 0, 206, 206, 657, 17, 72], ["+", 0, 57, 15, 666, 0, 206, 206, 657, 12, 22]]
5
70
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < ll(n); i++) int main() { int n, k; cin >> n >> k; vector<ll> a(n); rep(i, n) cin >> a[i]; for (int i = k; i < n; i++) { if (a[i - k + 1] < a[i]) puts("Yes"); else puts("No"); } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < ll(n); i++) int main() { int n, k; cin >> n >> k; vector<ll> a(n); rep(i, n) cin >> a[i]; for (int i = k; i < n; i++) { if (a[i - k] < a[i]) puts("Yes"); else puts("No"); } }
[["-", 51, 16, 31, 69, 341, 342, 0, 16, 17, 72], ["-", 51, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
1
106
N, K = map(int, input().split()) A = list(map(int, input().split())) sm = 1 for i in range(K): sm *= A[i] before = sm for i in range(K, N): sm /= A[i-K] sm *= A[i] if sm > before: print('Yes') else: print('No') before = sm
N, K = map(int, input().split()) A = list(map(int, input().split())) sm = 1 for i in range(K): sm += A[i] before = sm for i in range(K, N): sm -= A[i-K] sm += A[i] if sm > before: print('Yes') else: print('No') before = sm
[["-", 0, 7, 8, 196, 0, 1, 0, 677, 17, 108], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107], ["-", 0, 7, 8, 196, 0, 1, 0, 677, 17, 90], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 110]]
5
99
import sys def handler(): n, m = [int(i) for i in input().strip().split()] a = [int(i) for i in input().strip().split()] for i in range(m, n): if a[i] <= a[i - m]: sys.stdout.write('NO\n') else: sys.stdout.write('YES\n') def main(): while True: try: ...
import sys def handler(): n, m = [int(i) for i in input().strip().split()] a = [int(i) for i in input().strip().split()] for i in range(m, n): if a[i] <= a[i - m]: sys.stdout.write('No\n') else: sys.stdout.write('Yes\n') def main(): while True: try: ...
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["-", 0, 652, 3, 4, 0, 557, 0, 6, 0, 44], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 557, 0, 6, 0, 44]]
5
131
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int i, n, k, a[200020] = {}; scanf("%d %d", &n, &k); for (i = 1; i <= n; i++) { scanf("%d", &a[i]); } for (i = k + 1; i <= n; i++) { if (a[i - k] < a[i]) printf("Yes\n"); else ...
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int i, n, k, a[200020] = {}; scanf("%d %d", &n, &k); for (i = 1; i <= n; i++) { scanf("%d", &a[i]); } for (i = k + 1; i <= n; i++) { if (a[i - k] < a[i]) printf("Yes\n"); else ...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
122
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) #define ALL(obj) (obj).begin(), (obj).end() #d...
#include <bits/stdc++.h> //#include <boost/multiprecision/cpp_int.hpp> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("O3") #define REP(i, n) for (int i = 0; i < n; i++) #define REPP(i, n) for (int i = 1; i <= n; i++) #define ALL(obj) (obj).begin(), (obj).end() #d...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
1
396
#include <algorithm> #include <array> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <climits> #include <cmath> #include <cstdio> #include <iomanip> #include <unordered_map> #include <utility> ...
#include <algorithm> #include <array> #include <cstdlib> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define _USE_MATH_DEFINES #include <climits> #include <cmath> #include <cstdio> #include <iomanip> #include <unordered_map> #include <utility> ...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 90], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 110], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 108], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
238
N, K= map(int, input().split()) A = list(map(int, input().split())) for i in range(0,N-K): if A[i]<A[i+K]: print('yes') else: print('No')
N, K= map(int, input().split()) A = list(map(int, input().split())) for i in range(0,N-K): if A[i]<A[i+K]: print('Yes') else: print('No')
[["-", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 1, 0, 652, 3, 4, 0, 557, 0, 6]]
5
72
import sys import itertools def resolve(in_, out): n, k = map(int, next(in_).split()) a = tuple(map(int, next(in_).split())) b, c = itertools.tee(a) c = itertools.islice(c, k, None) for v, w in zip(b, c): s = 'Yes' if v < w else 'No' print(s, file=out) def main(): a...
import sys import itertools def resolve(in_, out): n, k = map(int, next(in_).split()) a = tuple(map(int, next(in_).split())) b, c = itertools.tee(a) c = itertools.islice(c, k, None) for v, w in zip(b, c): s = 'Yes' if v < w else 'No' print(s, file=out) def main(): r...
[["-", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 14, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22]]
5
135
n, k = map(int, input().split()) a = list(map(int, input().split())) point = 1 for i in range(n): if k > i: point *= a[i] continue now = point now //= a[i - k] now *= a[i] if now > point: print('Yes') else: print('No') point = now
n, k = map(int, input().split()) a = list(map(int, input().split())) point = 0 for i in range(n): if k > i: point += a[i] continue now = point now -= a[i - k] now += a[i] if now > point: print('Yes') else: print('No') point = now
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 0, 57, 64, 196, 0, 1, 0, 677, 17, 108], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["-", 0, 7, 8, 196, 0, 1, 0, 677, 17, 691], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 110], ["-", 0, 7, 8, 196, 0, 1, 0, 677, 17, 108], ["+...
5
95
N, K = map(int, input().strip().split(" ")) scores = input().strip().split(" ") for i in range(K, N): if (scores[i] > scores[i-K]): print("Yes") else: print("No")
N, K = map(int, input().strip().split(" ")) scores = input().strip().split(" ") for i in range(K, N): if (int(scores[i]) > int(scores[i-K])): print("Yes") else: print("No")
[["+", 0, 57, 15, 23, 0, 666, 0, 652, 63, 22], ["+", 15, 23, 0, 666, 0, 652, 3, 4, 0, 24], ["+", 15, 23, 0, 666, 0, 652, 3, 4, 0, 25]]
5
78
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; #define maxn 100005 int s[200005]; int main() { int ans = 0, a, b; cin >> a >> b; for (int i = 1...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; #define maxn 100005 int s[200005]; int main() { int ans = 0, a, b; cin >> a >> b; for (int i = 1...
[["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 51, 16, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 51, 16, 12, 69, 341, 342, 0, 16, 12, 22]]
1
130
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, k; cin >> n >> k; /// deque<ll> dq(n + 1, 1); /// deque<ll> p(n + 1, 1); deque<ll> dq = {1}; deque<ll> p = {1}; for (ll i = 1; i <= n; i++) { ll inp; cin >> inp; dq.push_back(inp); p.push_back(p....
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, k; cin >> n >> k; /// deque<ll> dq(n + 1, 1); /// deque<ll> p(n + 1, 1); deque<ll> dq = {0}; deque<ll> p = {0}; for (ll i = 1; i <= n; i++) { ll inp; cin >> inp; dq.push_back(inp); p.push_back(p....
[["-", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 48], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 85], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 85], ["+", 0, 57,...
1
171
n,k = map(int,input().split()) lis = list(map(int,input().split())) for i in range(k): if lis[i] < lis[i+k]: print("Yes") else: print("No")
n,k = map(int,input().split()) lis = list(map(int,input().split())) for i in range(n-k): if lis[i] < lis[i+k]: print("Yes") else: print("No")
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33]]
5
68
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define debug(n) cout << "DEBUG1 " << n << "\n"; #define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n"; #define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n"; #define debug4(n, m, x, y) ...
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define debug(n) cout << "DEBUG1 " << n << "\n"; #define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n"; #define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n"; #define debug4(n, m, x, y) ...
[["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 35], ["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46], ["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
1
1,206
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <string.h> #include <vector> using namespace std; #define set_precision cout << fixed << setprecision(10) #define rep(i, a, b) for (int i = a; i < b; i++) #define repb(i, a, ...
#include <algorithm> #include <bits/stdc++.h> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <map> #include <string.h> #include <vector> using namespace std; #define set_precision cout << fixed << setprecision(10) #define rep(i, a, b) for (int i = a; i < b; i++) #define repb(i, a, ...
[["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["-", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6]]
1
407
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; vector<int> v; for (int i = 0; i < n; i++) cin >> v[i]; for (int i = 0; i < n - k; i++) { if (v[i + k] > v[i]) cout << "Yes"; else cout << "No"; cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, k; cin >> n >> k; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; for (int i = 0; i < n - k; i++) { if (v[i + k] > v[i]) cout << "Yes"; else cout << "No"; cout << endl; } return 0; }
[["+", 8, 9, 0, 43, 49, 53, 54, 55, 0, 24], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 43, 49, 53, 54, 55, 0, 25]]
1
104
#include <bits/stdc++.h> #define ll long long using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = 1; i <= n; i++) ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); } using P = pair<int, int>; template <class T> bool chmax...
#include <bits/stdc++.h> #define ll long long using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = 1; i <= n; i++) ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); } using P = pair<int, int>; template <class T> bool chmax...
[["-", 0, 2, 3, 4, 0, 16, 31, 16, 31, 22], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 17, 72], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 18], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
257
#include <bits/stdc++.h> #define pb push_back #define int long long int #define INF 1e18 #define vec vector<int> #define REP(i, a, b) for (i = a; i < b; i++) using namespace std; main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, k; cin >> n >> k; int a[n + 1], i; for (i = 1;...
#include <bits/stdc++.h> #define pb push_back #define int long long int #define INF 1e18 #define vec vector<int> #define REP(i, a, b) for (i = a; i < b; i++) using namespace std; main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, k; cin >> n >> k; int a[n + 1], i; for (i = 1;...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
147
#!/usr/bin/env python3 import copy N, K = map(int, input().split()) A = list(map(int, input().split())) before = 1 for i in range(K, 0, -1): before *= A[K-i] for i in range(K, N): after = (before//A[i-K])*A[i] if before < after: print('Yes') else: print('No') before = copy.deepcopy...
#!/usr/bin/env python3 import copy N, K = map(int, input().split()) A = list(map(int, input().split())) before = 0 for i in range(K, 0, -1): before += A[K-i] for i in range(K, N): after = (before-A[i-K])+A[i] if before < after: print('Yes') else: print('No') before = copy.deepcopy(a...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 0, 7, 8, 196, 0, 1, 0, 677, 17, 108], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107], ["-", 0, 662, 12, 657, 31, 23, 0, 657, 17, 676], ["+", 0, 662, 12, 657, 31, 23, 0, 657, 17, 33], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 4...
5
114
#include <bits/stdc++.h> //#define int long long #define rep(i, l, r) for (register int i = l; i <= r; ++i) inline int read() { char cc = getchar(); int cn(0), flus(1); while (cc < '0' || cc > '9') { if (cc == '-') flus = -flus; cc = getchar(); } while (cc >= '0' && cc <= '9') { cn = cn * 1...
#include <bits/stdc++.h> //#define int long long #define rep(i, l, r) for (register int i = l; i <= r; ++i) inline int read() { char cc = getchar(); int cn(0), flus(1); while (cc < '0' || cc > '9') { if (cc == '-') flus = -flus; cc = getchar(); } while (cc >= '0' && cc <= '9') { cn = cn * 1...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 51, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 51, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
1
222
#include <bits/stdc++.h> using namespace std; int a[200001]; int main() { int n, k; cin >> n >> k; for (int i = 1; i <= k; i++) cin >> a[i]; for (int i = k + 1; i <= n; i++) { cin >> a[i]; if (a[i] >= a[i - k]) cout << "Yes\n"; else cout << "No\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int a[200001]; int main() { int n, k; cin >> n >> k; for (int i = 1; i <= k; i++) cin >> a[i]; for (int i = k + 1; i <= n; i++) { cin >> a[i]; if (a[i] > a[i - k]) cout << "Yes\n"; else cout << "No\n"; } return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
107
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A.at(i); } for (int i = 0; i < N - K + 1; i++) { cout << (A.at(i) < A.at(i + K - 1) ? "Yes" : "No") << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A.at(i); } for (int i = 0; i < N - K; i++) { cout << (A.at(i) < A.at(i + K) ? "Yes" : "No") << endl; } }
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 15, 16, 12, 2, 3, 4, 0, 16, 17, 33], ["-", 15, 16, 12, 2, 3, 4, 0, 16, 12, 13]]
1
109
import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int N = sc.nextInt(); int K = sc.nextInt(); int[] A = new int[N]; for (int i = 0; i < N; i++) { ...
import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int N = sc.nextInt(); int K = sc.nextInt(); int[] A = new int[N]; for (int i = 0; i < N; i++) { ...
[["-", 0, 492, 3, 4, 0, 510, 75, 5, 0, 491], ["+", 0, 492, 3, 4, 0, 510, 75, 5, 0, 491]]
3
162
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int[] A = new int[N]; for (int i = 0; i < N; i++) { A[i] = sc.nextInt(); } for (int i = K; i < N; i++) { if ...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int K = sc.nextInt(); int[] A = new int[N]; for (int i = 0; i < N; i++) { A[i] = sc.nextInt(); } for (int i = K; i < N; i++) { if ...
[["-", 0, 57, 15, 15, 0, 16, 12, 504, 71, 22], ["+", 0, 57, 15, 15, 0, 16, 12, 504, 71, 22], ["-", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 75, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 7, 8, 196, 0, 46]]
3
145
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define FOR(i, start, end) for (int i = start; i <= end; i++) const int INF = 1001001001; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define Sort(a) sort(a.begin(), a.end()) #define Rort(a) sort(a.rbegin(), a.rend()) type...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define FOR(i, start, end) for (int i = start; i <= end; i++) const int INF = 1001001001; #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define Sort(a) sort(a.begin(), a.end()) #define Rort(a) sort(a.rbegin(), a.rend()) type...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 108], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107], ["-", 8, 9, 0, 9, 0, 1, 0, 11, 17, 90], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 17, 110], ["-", 8, 9, 0, 9, 0, 1, 0, 11, 17, 108], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 17, 107]]
1
1,378
from sys import stdin nii=lambda:map(int,stdin.readline().split()) lnii=lambda:list(map(int,stdin.readline().split())) n,k=nii() a=lnii() for i in range(k,n): old=a[i-k] new=a[i] if old<p: print('Yes') else: print('No')
from sys import stdin nii=lambda:map(int,stdin.readline().split()) lnii=lambda:list(map(int,stdin.readline().split())) n,k=nii() a=lnii() for i in range(k,n): old=a[i-k] new=a[i] if old<new: print('Yes') else: print('No')
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22]]
5
98
import sys def input(): return sys.stdin.readline().rstrip() def main(): n = int(input()) A = list(map(int,input().split())) kabu = 0 kane = 1000 for i in range(n-1): if A[i+1] > A[i]: kabu = kane // A[i] kane %= A[i] elif A[i+1] < A[i]: kane += ka...
import sys def input(): return sys.stdin.readline().rstrip() def main(): n = int(input()) A = list(map(int,input().split())) kabu = 0 kane = 1000 for i in range(n-1): if A[i+1] > A[i]: kabu += kane // A[i] kane %= A[i] elif A[i+1] < A[i]: kane += k...
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]]
5
140
n = int(input()) a = list(map(int,input().split())) dp = [0]*(n) dp[0] = 1000 for i in range(1,n): tmp = dp[i-1] for j in range(i): k = dp[j]//a[j] m = dp[j]-a[j]*k tmp = max(tmp,m + a[i] * k) print(tmp) dp[i] = tmp print(dp[n-1])
n = int(input()) a = list(map(int,input().split())) dp = [0]*(n) dp[0] = 1000 for i in range(1,n): tmp = dp[i-1] for j in range(i): k = dp[j]//a[j] m = dp[j]-a[j]*k tmp = max(tmp,m + a[i] * k) dp[i] = tmp print(dp[n-1])
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
124
#include <iostream> #include <vector> using namespace std; int main() { long long N, s{}, ans{1000}; cin >> N; vector<int> A(N); for (auto &a : A) cin >> a; for (int i = 0; i != N; ++i) { if (i != N && A[i] < A[i + 1]) { s += ans / A[i]; ans -= ans / A[i] * A[i]; } else if (i == N || ...
#include <iostream> #include <vector> using namespace std; int main() { long long N, s{}, ans{1000}; cin >> N; vector<int> A(N); for (auto &a : A) cin >> a; for (int i = 0; i != N; ++i) { if (i != N - 1 && A[i] < A[i + 1]) { s += ans / A[i]; ans -= ans / A[i] * A[i]; } else if (i == N...
[["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 33], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 12, 13]]
1
151
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #define REP(i, n) for (int i = 0; i < n; i++) #define FOR(i, m, n) for (int i = m; i < n; i++) #define ALL(v) v.begin(), v.end() #define SIZE(x) ((int)(x).size()) using namespace std; typedef map<int, int> M; typedef pair<int, int> P; typedef long long ll; int m...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #define REP(i, n) for (int i = 0; i < n; i++) #define FOR(i, m, n) for (int i = m; i < n; i++) #define ALL(v) v.begin(), v.end() #define SIZE(x) ((int)(x).size()) using namespace std; typedef map<int, int> M; typedef pair<int, int> P; typedef long long ll; int m...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
167
N = int(input()) arr = list(map(int, input().split())) dp = [1000]*N for i in range(1,N): dp[i] = max((dp[i-1]//arr[i-1])*arr[i]+dp[i-1]%arr[i-1],dp[i-1]) print(dp)
N = int(input()) arr = list(map(int, input().split())) dp = [1000]*N for i in range(1,N): dp[i] = max((dp[i-1]//arr[i-1])*arr[i]+dp[i-1]%arr[i-1],dp[i-1]) print(dp[-1])
[["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["+", 0, 652, 3, 4, 0, 206, 206, 664, 17, 33], ["+", 0, 652, 3, 4, 0, 206, 206, 664, 28, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73]]
5
95
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long int ll; typedef pair<int, int> P; ll INF = 500; int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a[i]; a.insert(a.begin(), INF); a.push_back(0); ll ans = 1000, stock = 0, ...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long int ll; typedef pair<int, int> P; ll INF = 500; int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a[i]; a.insert(a.begin(), INF); a.push_back(0); ll ans = 1000, stock = 0, ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20]]
1
226
N=int(input()) A = list(map(int, input().split())) money=1000 stock=0 if A[0]<A[1]: stock=int(money/A[0]) money=money-A[i]*stock for i in range(1,N-1): if A[i-1]<A[i]: money=money+A[i]*stock stock=0 if A[i]<A[i+1]: stock=int(money/A[i]) money=money-A[i]*stock money=money+...
N=int(input()) A = list(map(int, input().split())) money=1000 stock=0 if A[0]<A[1]: stock=int(money/A[0]) money=money-A[0]*stock for i in range(1,N-1): if A[i-1]<A[i]: money=money+A[i]*stock stock=0 if A[i]<A[i+1]: stock=int(money/A[i]) money=money-A[i]*stock money=money+...
[["-", 0, 662, 12, 657, 12, 657, 31, 206, 206, 22], ["+", 0, 662, 12, 657, 12, 657, 31, 206, 206, 612]]
5
151
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define DEBUG(x) cout << #x << "=...
#include <algorithm> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; #define DEBUG(x) cout << #x << "=...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
569
#include <bits/stdc++.h> using namespace std; #define repd(i, a, b) for (ll i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) #define all(x) (x).begin(), (x).end() template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax...
#include <bits/stdc++.h> using namespace std; #define repd(i, a, b) for (ll i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) #define all(x) (x).begin(), (x).end() template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax...
[["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
296
n = int(input()) tmp = list(map(int, input().split())) arr = [tmp[0]] for i in range(1, n): if arr[-1] != tmp[i]: arr.append(tmp[i]) m, s = 1000, 0 for i in range(1, len(arr)): if arr[i - 1] < arr[i]: s += m // arr[i - 1] m -= m // arr[i - 1] * arr[i - 1] m += s * arr[i] ...
n = int(input()) tmp = list(map(int, input().split())) arr = [tmp[0]] for i in range(1, n): if arr[-1] != tmp[i]: arr.append(tmp[i]) m, s = 1000, 0 for i in range(1, len(arr)): if arr[i - 1] < arr[i]: s += m // arr[i - 1] m -= m // arr[i - 1] * arr[i - 1] m += s * arr[i] ...
[["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
135
#include <bits/stdc++.h> #include <fstream> using namespace std; typedef long long lint; #define rep(i, n) for (lint(i) = 0; (i) < (n); (i)++) #define repp(i, m, n) for (lint(i) = (m); (i) < (n); (i)++) #define repm(i, n) for (lint(i) = (n - 1); (i) >= 0; (i)--) #define INF (1ll << 60) #define all(x) (x).begin(), (x).e...
#include <bits/stdc++.h> #include <fstream> using namespace std; typedef long long lint; #define rep(i, n) for (lint(i) = 0; (i) < (n); (i)++) #define repp(i, m, n) for (lint(i) = (m); (i) < (n); (i)++) #define repm(i, n) for (lint(i) = (n - 1); (i) >= 0; (i)--) #define INF (1ll << 60) #define all(x) (x).begin(), (x).e...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 9, 0, 1, 0, 35]]
1
559
days = int(input()) price = list(map(int,input().split())) money = 1000 stock = 0 for i in range(days - 1): if price[i] < price[i + 1]: new = (money // price[i]) stock += new money -= (new * price[i]) else: money += stock * price[i] stock = 0 print(money,stock) print(money + stock * pri...
days = int(input()) price = list(map(int,input().split())) money = 1000 stock = 0 for i in range(days - 1): if price[i] < price[i + 1]: new = (money // price[i]) stock += new money -= (new * price[i]) else: money += stock * price[i] stock = 0 print(money + stock * price[-1])
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22]]
5
108
N = int(input()) A = list(map(int,input().split())) m = 1000 s = 0 flag = 0 a = A[0] for i in range(N): if A[i]>a and flag==0: n = m//a s += n m -= n*a flag = 1 a = A[i] elif A[i]<a and flag==1: m += s*a s = 0 flag = 0 a = A[i] if flag==1: ...
N = int(input()) A = list(map(int,input().split())) m = 1000 s = 0 flag = 0 a = A[0] for i in range(N): if A[i]>a and flag==0: n = m//a s += n m -= n*a flag = 1 elif A[i]<a and flag==1: m += s*a s = 0 flag = 0 a = A[i] if flag==1: m += s*A[-1] prin...
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["-", 64, 196, 0, 1, 0, 662, 12, 206, 51, 22], ["-", 64, 196, 0, 1, 0, 662, 12, 206, 0, 70], ["-", 64, 196, 0, 1, 0, 662, 12, 206, 206, 22], ["-", 64, 196, 0, 1, 0, 662, 12, 206, 0, 73]]
5
129
N = int(input()) A = list(map(int,input().split())) dp = [0] * N dp[0] = 1000 for i in range(1, N): dp[i] = dp[i - 1] for j in range(i - 1): V = dp[j] // A[j] W = dp[j] + (A[i] - A[j]) * V dp[i] = max(dp[i], W) print(dp[N - 1])
N = int(input()) A = list(map(int,input().split())) dp = [0] * N dp[0] = 1000 for i in range(1, N): dp[i] = dp[i - 1] for j in range(i): V = dp[j] // A[j] W = dp[j] + (A[i] - A[j]) * V dp[i] = max(dp[i], W) print(dp[N - 1])
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
123
/* [Template].cpp Example code to use when starting new code. This particular problem was problem 977A_Wrong_Subtraction from CodeForces Compile: g++ -o D.exe D.cpp Execute: ./D */ #include <bits/stdc++.h> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <limits> ...
/* [Template].cpp Example code to use when starting new code. This particular problem was problem 977A_Wrong_Subtraction from CodeForces Compile: g++ -o D.exe D.cpp Execute: ./D */ #include <bits/stdc++.h> #include <cmath> #include <cstdio> #include <cstring> #include <iomanip> #include <iostream> #include <limits> ...
[["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 87], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 12, 13], ["-", 0, 11, 12, 16, 12, 2, 3, 4, 0, 13], ["+", 0, 11, 12, 16, 12, 2, 3, 4, 0, 13]]
1
133
// #Sazaの1日1AC #include <bits/stdc++.h> using namespace std; const long long mod = 1000000000 + 7; const long long INF = 9e15; const double PI = 3.14159265358979323846; //マクロ //型エイリアス using ll = long long; using P = pair<long long, long long>; using vl = vector<long long>; using vvl = vector<vector<long long>>; using ...
// #Sazaの1日1AC #include <bits/stdc++.h> using namespace std; const long long mod = 1000000000 + 7; const long long INF = 9e15; const double PI = 3.14159265358979323846; //マクロ //型エイリアス using ll = long long; using P = pair<long long, long long>; using vl = vector<long long>; using vvl = vector<vector<long long>>; using ...
[["+", 0, 14, 8, 9, 0, 14, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 14, 8, 9, 0, 46]]
1
1,071
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i <= (int)(n); i++) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using pi = pair<int, int>; const ll INF = 1LL << 60; int main() { int n; cin >> n; vector<int> a(n); ...
#include "bits/stdc++.h" #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i <= (int)(n); i++) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using pi = pair<int, int>; const ll INF = 1LL << 60; int main() { int n; cin >> n; vector<int> a(n); ...
[["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 31, 22], ["+", 0, 11, 12, 16, 12, 23, 0, 16, 17, 33]]
1
166
// // M-SOLUTIONS 2020 // D // #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <ctime> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <tuple> #include <vector> using namespace std; #define REP(i, n) for (ll i = ...
// // M-SOLUTIONS 2020 // D // #include <algorithm> #include <bitset> #include <cassert> #include <cmath> #include <ctime> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <tuple> #include <vector> using namespace std; #define REP(i, n) for (ll i = ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]]
1
377
#include <bits/stdc++.h> using namespace std; int main() { int n; int money = 1000; int count = 0; cin >> n; vector<int> a(300); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n - 1; i++) { if (a[i] + 1 < a[i + 1]) { count = money / a[i]; money -= count * a[i]; //...
#include <bits/stdc++.h> using namespace std; int main() { int n; long long money = 1000; long long count = 0; cin >> n; vector<int> a(300); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n - 1; i++) { if (a[i] < a[i + 1]) { count = money / a[i]; money -= count * ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13]]
1
138
def inN(): return int(input()) def inL(): return list(map(int,input().split())) n = inN() a = inL() kab = 0 mon = 1000 f = [] i=0 state = 0 while(i < n-1): if state == 1: while(i<n-1): #print(a[i],a[i+1]) if a[i+1]>=a[i]: f.append(0) i+=1 ...
def inN(): return int(input()) def inL(): return list(map(int,input().split())) n = inN() a = inL() kab = 0 mon = 1000 f = [] i=0 state = 0 while(i < n-1): if state == 1: while(i<n-1): #print(a[i],a[i+1]) if a[i+1]>=a[i]: f.append(0) i+=1 ...
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
243
n = int(input()) A = tuple(map(int, input().split())) m = 1000 kabu = 0 for pa, aa in zip(A[:n], A[1:]): if pa < aa: # buy all kabu, m = divmod(m, pa) elif pa > aa: # sel all m += kabu * pa kabu = 0 if kabu > 0: m += kabu*aa print(m)
n = int(input()) A = tuple(map(int, input().split())) m = 1000 kabu = 0 for pa, aa in zip(A[:n], A[1:]): if pa < aa: # buy all kk, m = divmod(m, pa) kabu += kk elif pa > aa: # sel all m += kabu * pa kabu = 0 if kabu > 0: m += kabu*aa print(m)
[["-", 64, 196, 0, 1, 0, 662, 31, 684, 0, 22], ["+", 64, 196, 0, 1, 0, 662, 31, 684, 0, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 12, 22]]
5
95
#include <iostream> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } ll kane = 1000; ll kabu = 0; for (int i = 0; i < n - 1; i++) { if (a[i] < a[i + 1]) { kabu += k...
#include <iostream> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } ll kane = 1000; ll kabu = 0; for (int i = 0; i < n - 1; i++) { if (a[i] < a[i + 1]) { kabu += k...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 110], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 132]]
1
179
//#pragma GCC optimize("Ofast") //Comment optimisations for interactive //problems (use endl) #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> using namespace std; #define fastio \ ios::sync_with_stdio(0); ...
//#pragma GCC optimize("Ofast") //Comment optimisations for interactive //problems (use endl) #pragma GCC optimization ("unroll-loops") #include <bits/stdc++.h> using namespace std; #define fastio \ ios::sync_with_stdio(0); ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["-", 0, 57, 75, 76, 0, 1, 0, 11, 17, 107], ["-", 0, 57, 75, 76, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 75, 76, 0, 1, 0, 27, 17, 29]]
1
289
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int i = ...
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <string> #include <utility> #include <vector> #define rep(i, n) for (int i = ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
1
349
import sys readline = sys.stdin.buffer.readline def even(n): return 1 if n%2==0 else 0 n = int(readline()) lst1 = list(map(int,readline().split())) ct = 1000 stock = 0 #次の日に上がるか下がるか lst2 = [0]*n for i in range(n-1): if lst1[i] < lst1[i+1]: lst2[i] = 1 elif lst1[i] > lst1[i+1]: lst2[i] = -1 for ...
import sys readline = sys.stdin.buffer.readline def even(n): return 1 if n%2==0 else 0 n = int(readline()) lst1 = list(map(int,readline().split())) ct = 1000 stock = 0 #次の日に上がるか下がるか lst2 = [0]*n for i in range(n-1): if lst1[i] < lst1[i+1]: lst2[i] = 1 elif lst1[i] > lst1[i+1]: lst2[i] = -1 for ...
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]]
5
177
n = gets.to_i a = gets.split(" ").map(&:to_i).slice(0,n) BUY ="buy" SELL="sell" NO = "" chart =[] last =0 a.each_index{|d| action = NO if d == 0 action = BUY else if a[d] > a[d-1] action=SELL chart[d-1]=NO if chart[d-1] == SELL elsif a[d] < a[d-1] ...
n = gets.to_i a = gets.split(" ").map(&:to_i).slice(0,n) BUY ="buy" SELL="sell" NO = "" chart =[] last =0 a.each_index{|d| action = NO if d == 0 action = BUY else if a[d] >= a[d-1] action=SELL chart[d-1]=NO if chart[d-1] == SELL elsif a[d] < a[d-1] ...
[["-", 0, 121, 75, 95, 0, 121, 15, 738, 17, 47], ["+", 0, 121, 75, 95, 0, 121, 15, 738, 17, 20]]
4
245
n=int(input()) a=[int(i) for i in input().split()] s=0 m=1000 l=0 for i in range(1,n): if a[i-1]<a[i]: l=i if l==0: print(1000) exit() if l<n-1: for i in range(l): if a[i]<a[i+1]: s+=m//a[i] m-=a[i]*(m//a[i]) if a[i]>a[i+1]: m+=s*a[i] m=0 m+=s*a[l] else: for i in range(n-...
n=int(input()) a=[int(i) for i in input().split()] s=0 m=1000 l=0 for i in range(1,n): if a[i-1]<=a[i]: l=i if l==0: print(1000) exit() if l<n-1: for i in range(l): if a[i]<a[i+1]: s+=m//a[i] m-=a[i]*(m//a[i]) if a[i]>a[i+1]: m+=s*a[i] s=0 m+=s*a[l] else: for i in range(n...
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22]]
5
240
#include <bits/stdc++.h> using namespace std; int main(void) { int N; cin >> N; int A[N]; for (int i = 0; i < N; ++i) { cin >> A[i]; } int money = 1000; int stock = 0; bool is_down = true; for (int i = 0; i < N; ++i) { if (is_down && (A[i] < A[i + 1])) { stock += money / A[i]; m...
#include <bits/stdc++.h> using namespace std; int main(void) { int N; cin >> N; int A[N]; for (int i = 0; i < N; ++i) { cin >> A[i]; } long long money = 1000; long long stock = 0; bool is_down = true; for (int i = 0; i < N - 1; ++i) { if (is_down && (A[i] < A[i + 1])) { stock += money...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
181
#include <bits/stdc++.h> #define int long long using namespace std; typedef pair<int, int> P; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define INF 1000000000000 int MOD = 1000000007; struct edge { int to, cost; }; int modpow(int a, int x) { if (a < 0) a += MOD; int ans = 1; while (x > 0) { ...
#include <bits/stdc++.h> #define int long long using namespace std; typedef pair<int, int> P; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define INF 1000000000000 int MOD = 1000000007; struct edge { int to, cost; }; int modpow(int a, int x) { if (a < 0) a += MOD; int ans = 1; while (x > 0) { ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]]
1
498
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; vector<long> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } int M = 1000; int K = 1; for (int i = 0; i < N; i++) { if (K == 1) { if (A[i] < A[i + 1]) { K = M / A[i]; M -= K * A[i]; ...
#include <bits/stdc++.h> using namespace std; int main() { long long N; cin >> N; vector<long> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } long long M = 1000; long long K = 1; for (int i = 0; i < N; i++) { if (K == 1) { if (A[i] < A[i + 1]) { K = M / A[i]; M -= K * ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]]
1
253
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> //#include <boost/multiprecision/cpp_int.hpp> // // using namespace boost::multiprecision; using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> //#include <boost/multiprecision/cpp_int.hpp> // // using namespace boost::multiprecision; using namespace __gnu_pbds; using namespace std; typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_...
[["-", 0, 43, 49, 50, 51, 16, 12, 69, 28, 22], ["+", 0, 43, 49, 50, 51, 16, 12, 69, 28, 22]]
1
1,882
#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse4") #include "bits/stdc++.h" using namespace std; typedef long long ll; #define int ll #define all(x) x.begin(), x.end() #define trav(i, a) for (auto &i : a) inline int in() { int x; scanf("%lld", &x); return x; } int32_t main(...
#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse4") #include "bits/stdc++.h" using namespace std; typedef long long ll; #define int ll #define all(x) x.begin(), x.end() #define trav(i, a) for (auto &i : a) inline int in() { int x; scanf("%lld", &x); return x; } int32_t main(...
[["-", 15, 339, 51, 16, 12, 2, 63, 118, 28, 22], ["-", 15, 339, 51, 16, 12, 2, 63, 118, 17, 131], ["-", 15, 339, 51, 16, 12, 2, 63, 118, 119, 120], ["-", 15, 339, 51, 16, 12, 2, 3, 4, 0, 24], ["-", 15, 339, 51, 16, 12, 2, 3, 4, 0, 25], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13]]
1
373
n = int(input()) money = 1000 stock = 0 (*a,) = map(int, input().split()) for i in range(n - 1): if a[i] < a[i + 1]: stock = money // a[i] money = money % a[i] elif a[i] > a[i + 1]: money += stock * a[i] stock = 0 else: pass money += stock * a[-1] print(money)
n = int(input()) money = 1000 stock = 0 (*a,) = map(int, input().split()) for i in range(n - 1): if a[i] < a[i + 1]: stock += money // a[i] money = money % a[i] elif a[i] > a[i + 1]: money += stock * a[i] stock = 0 else: pass money += stock * a[-1] print(money)
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]]
5
111
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = 1; i < n; i++) using namespace std; using vi = vector<int>; int main() { int n; cin >> n; int64_t sum = 1000, k = 0; int wh = 0; vi Ai(n); vi kabu(n); rep(i, n) { cin >> Ai.at(i); } if (Ai.at(0) < Ai...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rrep(i, n) for (int i = 1; i < n; i++) using namespace std; using vi = vector<int>; int main() { int n; cin >> n; int64_t sum = 1000, k = 0; int wh = 0; vi Ai(n); vi kabu(n); rep(i, n) { cin >> Ai.at(i); } if (Ai.at(0) < Ai...
[["+", 64, 9, 0, 1, 0, 11, 12, 16, 31, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72]]
1
250
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(obj) (obj).begin(), (obj).end() #define debug(var) \ do { \ ...
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(obj) (obj).begin(), (obj).end() #define debug(var) \ do { \ ...
[["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73]]
1
610
N = int(input()) lst = list(map(int, input().split())) bs = [0]*N stock = 0 money = 1000 for i in range(1, N): if lst[i-1] < lst[i]: bs[i-1] = 1 if i > 1 and bs[i-2] == 1: bs[i-1] = -1 for i in range(N): if bs[i] == 1: stock = money // lst[i] money = money % lst[i] ...
N = int(input()) lst = list(map(int, input().split())) bs = [0]*N stock = 0 money = 1000 for i in range(1, N): if lst[i-1] < lst[i]: bs[i-1] = 1 if i > 1 and bs[i-2] != 0: bs[i-1] = -1 for i in range(N): if bs[i] == 1: stock = money // lst[i] money = money % lst[i] ...
[["-", 64, 196, 0, 57, 15, 679, 12, 666, 667, 60], ["-", 64, 196, 0, 57, 15, 679, 12, 666, 0, 612], ["+", 64, 196, 0, 57, 15, 679, 12, 666, 667, 79], ["+", 64, 196, 0, 57, 15, 679, 12, 666, 0, 612]]
5
181
N = int(input()) A = list(map(int,input().split())) money = 1000 cab = 0 lowprice = A[0] check = True for i in range(1,N): if(lowprice>A[i]): lowprice = A[i] check= True elif(lowprice<A[i] and check == True): high_price = A[i] if(i<=N-1): if(high_price > A[i+1]): ...
N = int(input()) A = list(map(int,input().split())) money = 1000 cab = 0 lowprice = A[0] check = True for i in range(1,N): if(lowprice>A[i]): lowprice = A[i] check= True elif((lowprice<A[i]) and (check == True)): high_price = A[i] if(i<N-1): if(high_price > A[i+1]): ...
[["+", 75, 665, 15, 23, 0, 679, 31, 23, 0, 24], ["+", 75, 665, 15, 23, 0, 679, 31, 23, 0, 25], ["+", 75, 665, 15, 23, 0, 679, 12, 23, 0, 24], ["+", 75, 665, 15, 23, 0, 679, 12, 23, 0, 25], ["-", 64, 196, 0, 57, 15, 23, 0, 666, 667, 19], ["+", 64, 196, 0, 57, 15, 23, 0, 666, 667, 18]]
5
172
n = int(input()) a = list(map(int,input().split())) b = [0]*n for i in range(n-1): if(a[i] < a[i+1]): #if(b[i-1] < 1): b[i] = 1 #else: # b[i] = 2 if(a[i] > a[i+1]): #if(b[i-1] > -1): b[i] = -1 #else: # b[i] = -2 #else: #if(b[i-1] ...
n = int(input()) a = list(map(int,input().split())) b = [0]*n for i in range(n-1): if(a[i] < a[i+1]): #if(b[i-1] < 1): b[i] = 1 #else: # b[i] = 2 if(a[i] > a[i+1]): #if(b[i-1] > -1): b[i] = -1 #else: # b[i] = -2 #else: #if(b[i-1] ...
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
195
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int n; cin >> n; int a[n]; ll money = 1000; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n - 2; i++) { ll stocks = 0; if (a[i] < a[i + 1]) stocks = money / a[i]; money += (a[i + 1] - a[i]) ...
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int n; cin >> n; ll a[n]; ll money = 1000; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n - 1; i++) { ll stocks = 0; if (a[i] < a[i + 1]) stocks = money / a[i]; money += (a[i + 1] - a[i]) *...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
124
input() A=list(map(int,input().split())) M=[0,1000] for i in range(0,len(A)-1): if A[i]>A[i+1]: M[1]+=A[i]*M[0] M[0]=0 elif A[i]<A[i+1]: M[0]+=int(M[1]/A[i]) M[1]=M[1]%A[i] M[1]+=A[i+1]*M[0] M[0]=0 print(M)
input() A=list(map(int,input().split())) M=[0,1000] for i in range(0,len(A)-1): if A[i]>A[i+1]: M[1]+=A[i]*M[0] M[0]=0 elif A[i]<A[i+1]: M[0]+=int(M[1]/A[i]) M[1]=M[1]%A[i] M[1]+=A[i+1]*M[0] M[0]=0 print(M[1])
[["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 70], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 206, 612], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 0, 73]]
5
145
//コンパイラ最適化用 #pragma GCC optimize("Ofast") //インクルード(アルファベット順) #include <algorithm> //sort,二分探索,など #include <bitset> //固定長bit集合 #include <chrono> //実行時間計測 #include <cmath> //pow,logなど #include <complex> //複素数 #include <deque> //両端アクセスのキュー #include <functional> //sortのgreater #in...
//コンパイラ最適化用 #pragma GCC optimize("Ofast") //インクルード(アルファベット順) #include <algorithm> //sort,二分探索,など #include <bitset> //固定長bit集合 #include <chrono> //実行時間計測 #include <cmath> //pow,logなど #include <complex> //複素数 #include <deque> //両端アクセスのキュー #include <functional> //sortのgreater #in...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
195
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using v1 = vector<int>; using vl = vector<long long>; using v2 = vector<vector<int>>; using v3 = vector<vector<char>>; int main() { int n; cin >> n; v1 a(n + 1); rep(i, n) { cin >> a[i + 1]; } ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using v1 = vector<int>; using vl = vector<long long>; using v2 = vector<vector<int>>; using v3 = vector<vector<char>>; int main() { int n; cin >> n; v1 a(n + 1); rep(i, n) { cin >> a[i + 1]; } ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13]]
1
187
#include <cmath> #include <iostream> using namespace std; int main() { int N; cin >> N; int arr[N]; for (int i = 0; i < N; i++) cin >> arr[i]; long long ans = 1000; for (int i = 0; i < N; i++) { int mini = 1e8; while (i < N && arr[i] <= mini) mini = arr[i++]; int maks = 0; while (i...
#include <cmath> #include <iostream> using namespace std; int main() { int N; cin >> N; int arr[N]; for (int i = 0; i < N; i++) cin >> arr[i]; long long ans = 1000; for (int i = 0; i < N;) { int mini = 1e8; while (i < N && arr[i] <= mini) mini = arr[i++]; int maks = 0; while (i < N...
[["-", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22], ["-", 0, 14, 8, 9, 0, 7, 26, 27, 17, 29]]
1
144
def main(): n = int(input()) A = list(map(int, input().split())) ans = 1000 t, p = [], [] if A[0] < A[1]: t.append(0) for i in range(1, n - 1): if A[i - 1] >= A[i] < A[i + 1]: t.append(i) elif A[i - 1] <= A[i] > A[i + 1]: p.append(i) b = 0 ...
def main(): n = int(input()) A = list(map(int, input().split())) ans = 1000 t, p = [], [] if A[0] < A[1]: t.append(0) for i in range(1, n - 1): if A[i - 1] >= A[i] < A[i + 1]: t.append(i) elif A[i - 1] <= A[i] > A[i + 1]: p.append(i) b = 0 ...
[["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
203
#include <bits/stdc++.h> using namespace std; struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } fast; using namespace std; typedef long long ll; typedef pair<ll, ll> P; long long mod = 1000000007; #define REP(i, n) for (long long i = 0; i < (n); i++) ...
#include <bits/stdc++.h> using namespace std; struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } fast; using namespace std; typedef long long ll; typedef pair<ll, ll> P; long long mod = 1000000007; #define REP(i, n) for (long long i = 0; i < (n); i++) ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]]
1
681
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MM = 1000000000; const int MOD = MM + 7; const int MAX = 510000; #define rep(i, n) for (ll i = 0; i < n; i++) #define Rep(i, j, n) for (ll i = j; i < n; i++) #define all(vec) vec.begin(), vec.end() template <class T> inline bool chmin(T &a, T...
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MM = 1000000000; const int MOD = MM + 7; const int MAX = 510000; #define rep(i, n) for (ll i = 0; i < n; i++) #define Rep(i, j, n) for (ll i = j; i < n; i++) #define all(vec) vec.begin(), vec.end() template <class T> inline bool chmin(T &a, T...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]]
1
257
n = int(input()) a = [0] + list(map(int, input().split())) ''' ans = 1000 for i in range(n - 1): x = a[i] y = a[i + 1] if x < y: k = ans // x ans %= x ans += k * y print(ans) ''' dp = [0] * (n + 10) dp[1] = 1000 for i in range(2, n + 1): dp[i] = dp[i - 1] for j in range(1,...
n = int(input()) a = [0] + list(map(int, input().split())) ''' ans = 1000 for i in range(n - 1): x = a[i] y = a[i + 1] if x < y: k = ans // x ans %= x ans += k * y print(ans) ''' dp = [0] * (n + 10) dp[1] = 1000 for i in range(2, n + 1): dp[i] = dp[i - 1] for j in range(1,...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
139
n = int(input()) a = list(map(int,input())) money = 1000 stock = 0 for i in range(n-1): if a[i+1] > a[i]: stock = money // a[i] money = money - stock*a[i] + stock*a[i+1] print(money)
n = int(input()) a = list(map(int,input().split())) money = 1000 stock = 0 for i in range(n-1): if a[i+1] > a[i]: stock = money // a[i] money = money - stock*a[i] + stock*a[i+1] print(money)
[["+", 0, 652, 3, 4, 0, 652, 63, 319, 0, 131], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
81
#include <algorithm> #include <bits/stdc++.h> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; /*define*/ #define rep(i, n) for (int i = 0; i < n; ++i) #define endl "\n" typedef long long ll...
#include <algorithm> #include <bits/stdc++.h> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; /*define*/ #define rep(i, n) for (int i = 0; i < n; ++i) #define endl "\n" typedef long long ll...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]]
1
276
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; using namespace std; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) { cin >> a[i]; } ll x = 1000; rep(i, n - 1) { int s = a[i]; int t = a[i - 1]; if (s < t) { ll k = x / s; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using ll = long long; using namespace std; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) { cin >> a[i]; } ll x = 1000; rep(i, n - 1) { int s = a[i]; int t = a[i + 1]; if (s < t) { ll k = x / s; ...
[["-", 49, 50, 51, 69, 341, 342, 0, 16, 17, 33], ["+", 49, 50, 51, 69, 341, 342, 0, 16, 17, 72]]
1
125
n,*a=open(0).read().split() x=1000 for i in range(n-1):x+=x//a[i]*max(0,a[i+1]-a[i]) print(x)
n,*a=map(int,open(0).read().split()) x=1000 for i in range(n-1):x+=x//a[i]*max(0,a[i+1]-a[i]) print(x)
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
59
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; using pint = pair<int, int>; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; const int MOD = 1000000009; const long long INF = 1LL << 60; int main() { ll N; cin >> N; vector<ll> A(N); for (int i = 0; i...
#include <bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; using pint = pair<int, int>; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; const int MOD = 1000000009; const long long INF = 1LL << 60; int main() { ll N; cin >> N; vector<ll> A(N); for (int i = 0; i...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 151], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 12...
1
246
n=int(input()) a=[float('Inf')] a+=list(map(int,input().split())) i=0 m=1000 while i<n: if a[i]>a[i+1]: s=a[i+1] if a[i]<a[i+1]: m=m//s*a[i+1]+m%s s=i+1 i+=1 print(m)
n=int(input()) a=[float('Inf')] a+=list(map(int,input().split())) i=0 m=1000 while i<n: if a[i]>a[i+1]: s=a[i+1] if a[i]<a[i+1]: m=m//s*a[i+1]+m%s s=a[i+1] i+=1 print(m)
[["+", 64, 196, 0, 1, 0, 662, 12, 206, 51, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 206, 0, 70], ["+", 64, 196, 0, 1, 0, 662, 12, 206, 0, 73]]
5
108
N = int(input()) A = list(map(int, input().split())) yen = 1000 stocks = 0 for i in range(N): if i == N-1: yen += stocks * A[i] stocks = 0 break if A[i] > A[i-1]: # sell everything yen += stocks * A[i] stocks = 0 else: # buy everything num = yen // A[i] stocks += num y...
N = int(input()) A = list(map(int, input().split())) yen = 1000 stocks = 0 for i in range(N): if i == N-1: yen += stocks * A[i] stocks = 0 break if A[i] > A[i+1]: # sell everything yen += stocks * A[i] stocks = 0 else: # buy everything num = yen // A[i] stocks += num y...
[["-", 0, 57, 15, 666, 0, 206, 206, 657, 17, 33], ["+", 0, 57, 15, 666, 0, 206, 206, 657, 17, 72]]
5
109
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N; cin >> N; vector<ll> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } ll stock = 0; ll money = 1000; for (int i = 0; i < N - 1; i++) { ll max_j = i; ll max_price = A[i]; for (int j = i + 1; j < ...
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int N; cin >> N; vector<ll> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } ll stock = 0; ll money = 1000; for (int i = 0; i < N - 1; i++) { ll max_j = i; ll max_price = A[i]; for (int j = i + 1; j < ...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
199
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; vector<long long int> a(n); for (auto &x : a) cin >> x; long long int money = 1000; for (int i = 0; i < n; i++) { long long int stocks = money / a[i]; money += stocks * max(a[i + 1] - a[i], 0LL); } cout <...
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; vector<long long int> a(n); for (auto &x : a) cin >> x; long long int money = 1000; for (int i = 0; i < n - 1; i++) { long long int stocks = money / a[i]; money += stocks * max(a[i + 1] - a[i], 0LL); } co...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
109
def 買う(株, 金, 株価): 株 = 金 // 株価 金 = 金 - 株*株価 return 株, 金 def 売る(株, 金, 株価): 金 = 金 + 株*株価 株 = 0 return 株, 金 n = int(input()) 株価 = [int(i) for i in input().split()] 株価.append(-1) 株 = 0 金 = 1000 for i in range(n): if 株価[i] < 株価[i+1]: 株, 金 = 買う(株, 金, 株価[i]) else: 株, 金 = 売る(株...
def 買う(株, 金, 株価): 買う株 = 金 // 株価 金 = 金 - 買う株*株価 株 += 買う株 return 株, 金 def 売る(株, 金, 株価): 金 = 金 + 株*株価 株 = 0 return 株, 金 n = int(input()) 株価 = [int(i) for i in input().split()] 株価.append(-1) 株 = 0 金 = 1000 for i in range(n): if 株価[i] < 株価[i+1]: 株, 金 = 買う(株, 金, 株価[i]) else: ...
[["-", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 1, 0, 662, 12, 657, 12, 657, 31, 22], ["+", 0, 1, 0, 662, 12, 657, 12, 657, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 14, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 14, 8, 196, 0, 1, 0, 677, 12, 22]]
5
146
n = int(input()) given_A = list(map(int, input().split())) A = [] for kabuka in given_A: if len(A) > 0 and kabuka == A[-1]: continue else: A.append(kabuka) print(A) # 株価が全て同じ時のコーナーケース if len(A) == 1: print(1000) exit() money = 1000 stock = 0 n = len(A) for i in range(len(A)): i...
n = int(input()) given_A = list(map(int, input().split())) A = [] for kabuka in given_A: if len(A) > 0 and kabuka == A[-1]: continue else: A.append(kabuka) # 株価が全て同じ時のコーナーケース if len(A) == 1: print(1000) exit() money = 1000 stock = 0 n = len(A) for i in range(len(A)): if i == 0: ...
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
258
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i < (int)(n); i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define debug(var) \ do { ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, n) for (int i = 1; i < (int)(n); i++) #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define debug(var) \ do { ...
[["-", 0, 2, 3, 4, 0, 16, 12, 16, 12, 22], ["+", 3, 4, 0, 16, 12, 16, 12, 69, 28, 22], ["+", 0, 16, 12, 16, 12, 69, 341, 342, 0, 70], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 16, 12, 16, 12, 69, 341, 342, 0, ...
1
416
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a; int pre = 0, now; for (int i = 0; i < n; i++) { cin >> now; if (pre != now) a.push_back(now); pre = now; } if (a.size() == 1) { cout << 1000 << endl; return 0; } else if (a.size() == 2) ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a; int pre = 0, now; for (int i = 0; i < n; i++) { cin >> now; if (pre != now) a.push_back(now); pre = now; } if (a.size() == 1) { cout << 1000 << endl; return 0; } else if (a.size() == 2) ...
[["-", 12, 16, 12, 23, 0, 16, 31, 69, 28, 22], ["+", 12, 16, 12, 23, 0, 16, 31, 69, 28, 22], ["-", 12, 16, 12, 23, 0, 16, 12, 69, 28, 22], ["+", 12, 16, 12, 23, 0, 16, 12, 69, 28, 22]]
1
374
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; int asset = 1000; int stock = 0; rep(i, n - 1) { if (a[i] < a[i + 1]) { int ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; ll asset = 1000; ll stock = 0; rep(i, n - 1) { if (a[i] < a[i + 1]) { ll add...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 9, 0, 57, 64, 9, 0, 43, 39, 40], ["+", 0, 9, 0, 57, 64, 9, 0, 43, 39, 78], ["-", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["+", 15, 339, 51, 16, 12, 69, 341, 342, 0, 22], ["-", 51, 16, 31, 69, 341, 342, 0, 16, 31, 22], ["+",...
1
244
#------------- N = int(input()) A = list(map(int, input().split())) #------------- kabu = 0 money = 1000 for i in range(N-1): if A[i] < A[i+1]: mod,money = divmod(money , A[i]) kabu += mod else: money = money + A[i+1] * kabu kabu = 0 money = money + A[N-1]*kabu print(money)
#------------- N = int(input()) A = list(map(int, input().split())) #------------- kabu = 0 money = 1000 for i in range(N-1): if A[i] < A[i+1]: mod,money = divmod(money , A[i]) kabu += mod else: money = money + A[i] * kabu kabu = 0 money = money + A[N-1]*kabu print(money)
[["-", 12, 657, 12, 657, 31, 206, 206, 657, 17, 72], ["-", 12, 657, 12, 657, 31, 206, 206, 657, 12, 612]]
5
105
# from math import factorial as fac from collections import defaultdict # from copy import deepcopy import sys, math f = None try: f = open('q1.input', 'r') except IOError: f = sys.stdin if 'xrange' in dir(__builtins__): range = xrange # print(f.readline()) # sys.setrecursionlimit(10**6) def print_case_iterable...
# from math import factorial as fac from collections import defaultdict # from copy import deepcopy import sys, math f = None try: f = open('q1.input', 'r') except IOError: f = sys.stdin if 'xrange' in dir(__builtins__): range = xrange # print(f.readline()) # sys.setrecursionlimit(10**6) def print_case_iterable...
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["-", 75, 665, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 75, 665, 64, 196, 0, 1, 0, 677, 17, 107]]
5
1,859
line = gets prices = gets.split(' ').map(&:to_i) have_money = 1000 kabu_num = 0 last_sell = false prices.each_with_index do |price,i| break if prices[i+1].nil? if price < prices[i+1] # puts '買い' last_sell = true next if kabu_num != 0 # 株を保持してて買いの時はそのまま保持なので kabu_num = (have_money / price) hav...
line = gets prices = gets.split(' ').map(&:to_i) have_money = 1000 kabu_num = 0 last_sell = false prices.each_with_index do |price,i| break if prices[i+1].nil? if price < prices[i+1] # puts '買い' last_sell = true next if kabu_num != 0 # 株を保持してて買いの時はそのまま保持なので kabu_num = (have_money / price) hav...
[["+", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 36, 36, 0, 493, 0, 652, 3, 4, 0, 22]]
4
127
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; int main() { cin.tie(0)->sync_with_stdio(false); int n; cin >> n; vector<ll> a(n); REP(i, n) cin >> a[i]; ll res = 1000; ll stock = 0; REP(i, n - 1) { if (a[i] < a[i + 1] && res > 0...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; int main() { cin.tie(0)->sync_with_stdio(false); int n; cin >> n; vector<ll> a(n); REP(i, n) cin >> a[i]; ll res = 1000; ll stock = 0; REP(i, n - 1) { if (a[i] < a[i + 1] && res >= ...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20], ["+", 15, 339, 51, 16, 12, 16, 12, 69, 28, 22], ["+", 51, 16, 12, 16, 12, 69, 341, 342, 0, 70], ["+", 51, 16, 12, 16, 12, 69, 341, 342, 0, 22], ["+", 51, 16, 12, 16, 12, 69, 341,...
1
179
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a.at(i); int stock = 0; int balance = 1000; for (int i = 0; i < n - 1; ++i) { if (a.at(i) < ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; int main() { int n; cin >> n; vector<ll> a(n); rep(i, n) cin >> a.at(i); ll stock = 0; ll balance = 1000; for (int i = 0; i < n - 1; ++i) { if (a.at(i) < a.a...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 75, 76, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 75, 76, 0, 9, 0, 1, 0, 11, 17, 107]]
1
211