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=int(input())
A=list(map(int,input().split()))
G=1000
K=0
for i in range(N-1):
if A[i+1]>A[i]:
K=int(G/A[i])
G=G % A[i]
if A[i+1]<A[i]:
G=G+A[i]*K
K=0
G=G+A[N-1]*K
print(G) | N=int(input())
A=list(map(int,input().split()))
G=1000
K=0
for i in range(N-1):
if A[i+1]>A[i]:
K=K+G//A[i]
G=G % A[i]
if A[i+1]<A[i]:
G=G+A[i]*K
K=0
G=G+A[N-1]*K
print(G) | [["-", 64, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["-", 0, 662, 12, 652, 3, 4, 0, 657, 17, 85], ["+", 0, 1, 0, 662, 12, 657, 12, 657, 17, 676], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]... | 5 | 115 |
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x... | #include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x... | [["+", 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, 69, 341, 342, 0, 16, 12, 13]] | 1 | 537 |
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x... | #include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x... | [["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 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 | 498 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uint = unsigned;
using pcc = pair<char, char>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using tuplis = array<ll, 3>;
template <class T> using p... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uint = unsigned;
using pcc = pair<char, char>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using tuplis = array<ll, 3>;
template <class T> using p... | [["+", 64, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]] | 1 | 3,864 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll>
#define pint pair<int, int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 100000000... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll>
#define pint pair<int, int>
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mod 100000000... | [["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 0, 9, 0, 1, 0, 11, 12, 16, 12, 13]] | 1 | 622 |
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
long long a[100];
for (int i = 0; i < n; i++) {
scanf("%lld", &a[i]);
}
long long nums = 0;
long long nSum = 1000;
long long nMin;
for (long long i = 0; i < n;) {
nMin = a[i];
bool res = 1;
for (long long j = i + 1; j < n; j++) {... | #include <stdio.h>
int main() {
int n;
scanf("%d", &n);
long long a[100];
for (int i = 0; i < n; i++) {
scanf("%lld", &a[i]);
}
long long nums = 0;
long long nSum = 1000;
long long nMin;
for (long long i = 0; i < n;) {
nMin = a[i];
bool res = 1;
for (long long j = i + 1; j < n; j++) {... | [["-", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 22], ["-", 15, 339, 51, 16, 31, 69, 341, 342, 0, 73], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]] | 1 | 195 |
n = int(input())
a = list(map(int, input().split()))
money = 1000
peak = []
botom = []
kabu = 0
if a[0] < a[1]:
botom.append(0)
if a[n-1] >= a[n-2]:
peak.append(n-1)
for i in range(1, n-1):
if a[i] >= a[i-1] and a[i] > a[i+1]:
peak.append(i)
if a[i] <= a[i-1] and a[i] < a[i+1]:
botom.ap... | n = int(input())
a = list(map(int, input().split()))
money = 1000
peak = []
botom = []
kabu = 0
if a[0] < a[1]:
botom.append(0)
if a[n-1] >= a[n-2]:
peak.append(n-1)
for i in range(1, n-1):
if a[i] >= a[i-1] and a[i] > a[i+1]:
peak.append(i)
if a[i] <= a[i-1] and a[i] < a[i+1]:
botom.ap... | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]] | 5 | 200 |
#include <algorithm>
#include <cmath> //abs()かfabs()で少数絶対値
#include <cstdlib> //abs()で整数絶対値
#include <deque>
#include <functional> //sort第三引数greater<型名>()で降順
#include <iomanip> //cout<<setw(数字) で空白による桁揃え
#include <iostream> //cout<<right で右揃え
#include <map>
#include <queue>
#include <string>
#include <vector>
u... | #include <algorithm>
#include <cmath> //abs()かfabs()で少数絶対値
#include <cstdlib> //abs()で整数絶対値
#include <deque>
#include <functional> //sort第三引数greater<型名>()で降順
#include <iomanip> //cout<<setw(数字) で空白による桁揃え
#include <iostream> //cout<<right で右揃え
#include <map>
#include <queue>
#include <string>
#include <vector>
u... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 1 | 282 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
int n;
ll a[100];
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
REP(i, n) cin >> a[i];
ll tmp = 1000;
ll st = 0;
bool flag = false;
int last = 0;
REP(i, n)... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
int n;
ll a[100];
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
REP(i, n) cin >> a[i];
ll tmp = 1000;
ll st = 0;
bool flag = false;
int last = 0;
REP(i, n)... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 147], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]] | 1 | 192 |
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define per(i, a, n) for (int i = (a); i > (n); i--)
typedef long long ll;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
using namespace std;
ll a[maxn];
void solve() {
ll n, cur = 0, fee = 1000;
cin >> n;
... | #include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define per(i, a, n) for (int i = (a); i > (n); i--)
typedef long long ll;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
using namespace std;
ll a[maxn];
void solve() {
ll n, cur = 0, fee = 1000;
cin >> n;
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 20], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 19], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 2... | 1 | 444 |
n=int(input())
a=list(map(int,input().split()))
ans=1000
kabu=0
flag=0
for i in range(n-1):
if a[i]<a[i+1]:
if flag !=1:
kabu=int(ans/a[i])
ans-=(kabu*a[i])
#print(a[i],ans,kabu)
flag=1
elif a[i]>a[i+1]:
if flag >0:
ans+=(kabu*a[i])
... | n=int(input())
a=list(map(int,input().split()))
ans=1000
kabu=0
flag=0
for i in range(n-1):
if a[i]<a[i+1]:
if flag <=0:
kabu=int(ans/a[i])
ans-=(kabu*a[i])
#print(a[i],ans,kabu)
flag=1
elif a[i]>a[i+1]:
if flag >0:
ans+=(kabu*a[i])
... | [["-", 0, 57, 64, 196, 0, 57, 15, 666, 667, 79], ["-", 0, 57, 64, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 612]] | 5 | 166 |
K = int(input())
A = list(map(int, input().split()))
sum = 1000
kabu = 0
for k in range(K):
if k+1 ==K:
sum +=kabu*A[K-1]
break
if A[k]<A[k+1] and A[k]<=sum:
S = int(sum/A[k])
sum = sum-A[k]*S
kabu +=S
elif A[k]>A[k+1] and kabu != 0:
sum = sum + kabu * A[k]
... | K = int(input())
A = list(map(int, input().split()))
sum = 1000
kabu = 0
for k in range(K):
if k+1 ==K:
sum +=kabu*A[K-1]
break
if A[k]<A[k+1] and A[k]<=sum:
S = int(sum/A[k])
sum = sum-A[k]*S
kabu +=S
elif A[k]>A[k+1] and kabu != 0:
sum = sum + kabu * A[k]
... | [["-", 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 | 139 |
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pair<l... | #pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pair<l... | [["-", 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, 342, 0, 73], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 450 |
n = int(input())
a = list(map(int, input().split()))
mon = 1000
for i in range(1, n):
if a[i-1] < a[i]:
kb = mon // a[i-1]
mon %= a[i-1]
mon += kb * a[i]
print(kb, mon)
print(mon)
| n = int(input())
a = list(map(int, input().split()))
mon = 1000
for i in range(1, n):
if a[i-1] < a[i]:
kb = mon // a[i-1]
mon %= a[i-1]
mon += kb * a[i]
print(mon)
| [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 64, 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]] | 5 | 87 |
import numpy as np
n=int(input())
a = list(map(int, input().split()))
m = 1000
kabu = 0
for i in range(n-1):
if a[i] < a[ i +1 ]:
kabu = int((m - (m % a[i])) / a[i])
m = m % a[i]
elif a[i] > a[ i +1 ]:
m = m + (a[i] * kabu)
kabu = 0
if kabu > 0:
m = m + kabu * a[-1]
print(m) | import numpy as np
n=int(input())
a = list(map(int, input().split()))
m = 1000
kabu = 0
for i in range(n-1):
if a[i] < a[ i +1 ]:
kabu = kabu + int((m - (m % a[i])) / a[i])
m = m % a[i]
elif a[i] > a[ i +1 ]:
m = m + (a[i] * kabu)
kabu = 0
if kabu > 0:
m = m + kabu * a[-1]
print(m) | [["+", 64, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 17, 72]] | 5 | 136 |
N = int(input())
A = list(map(int,input().split()))
m = 1000
k = 0
for i in range(N-1):
if A[i] < A[i+1]:
k = m // A[i]
m = m % A[i]
elif A[i] > A[i+1]:
m += k * A[i]
k = 0
m += k * A[N-1]
print(m) | N = int(input())
A = list(map(int,input().split()))
m = 1000
k = 0
for i in range(N-1):
if A[i] < A[i+1]:
k += m // A[i]
m = m % A[i]
elif A[i] > A[i+1]:
m += k * A[i]
k = 0
m += k * A[N-1]
print(m) | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]] | 5 | 108 |
N = int(input())
A = list(map(int,input().split()))
reverseA = sorted(A,reverse = True)
money = 1000
stock = 0
if A == reverseA:
print(money)
else:
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 +=... | N = int(input())
A = list(map(int,input().split()))
reverseA = sorted(A,reverse = True)
money = 1000
stock = 0
if A == reverseA:
print(money)
else:
for i in range(N-1):
if A[i] < A[i+1]:
if stock == 0:
stock = money // A[i]
money = money % A[i]
elif ... | [["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 667, 60], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 612], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 102], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22]] | 5 | 140 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int A[N + 1];
for (int i = 1; i <= N; i++) {
cin >> A[i];
}
unsigned long int currentMoney = 1000, kabu = 0;
for (int i = 1; i < N; i++) {
if (A[i] < A[i + 1]) {
kabu = currentMoney / A[i];
currentMoney = cu... | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int A[N + 1];
for (int i = 1; i <= N; i++) {
cin >> A[i];
}
unsigned long int currentMoney = 1000, kabu = 0;
for (int i = 1; i < N; i++) {
if (A[i] < A[i + 1]) {
kabu += currentMoney / A[i];
currentMoney = c... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 1 | 169 |
n = int(input(''))
alist = list(map(int,input('').split()))
money=1000
stock=0
for d in range(n-1):
if stock ==0:
if alist[d+1] > alist[d]:
# 明日上がるなら買い
stock+=int(money/alist[d])
money-=stock*alist[d]
else:
# 明日下がる場合は何もしない
pass
else:
... | n = int(input(''))
alist = list(map(int,input('').split()))
money=1000
stock=0
for d in range(n-1):
if stock ==0:
if alist[d+1] > alist[d]:
# 明日上がるなら買い
stock=int(money/alist[d])
money-=stock*alist[d]
else:
# 明日下がる場合は何もしない
pass
else:
... | [["-", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32]] | 5 | 161 |
#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>;
using G = vector<vector<int>>;
int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
int money = 1000;
int kabu = 0;
// int flag = 0;
vector<int... | #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>;
using G = vector<vector<int>>;
int main() {
int n;
cin >> n;
vector<ll> a(n);
rep(i, n) cin >> a[i];
ll money = 1000;
ll kabu = 0;
// int flag = 0;
vector<int> k... | [["-", 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], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 1 | 233 |
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cstdint> // int64_t, int*_t
#include ... | #pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cstdint> // int64_t, int*_t
#include ... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20]] | 1 | 330 |
N = int(input())
A = list(map(int,input().split()))
ans = 1000
diff = [0 for _ in range(N)]
for i in range(1, N):
if A[i] == A[i - 1]: diff[i] = 0
elif A[i] > A[i - 1]: diff[i] = 1
else: diff[i] = -1
money = 1000
kabu = 0
for i in range(1, N):
if kabu == 0:
if diff[i] == 1:
kab... | N = int(input())
A = list(map(int,input().split()))
ans = 1000
diff = [0 for _ in range(N)]
for i in range(1, N):
if A[i] == A[i - 1]: diff[i] = 0
elif A[i] > A[i - 1]: diff[i] = 1
else: diff[i] = -1
money = 1000
kabu = 0
for i in range(1, N):
if kabu == 0:
if diff[i] == 1:
kab... | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["-", 64, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 110], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]] | 5 | 201 |
N = int(input())
A = list(map(int, input().split())) + [0]
money = 1000
stock = 0
prev = 201
for i,price in enumerate(A):
if price > prev:
stock += money // prev
money -= stock * prev
elif price < prev and stock:
money += prev * stock
stock = 0
prev = price
print(money)
| N = int(input())
A = list(map(int, input().split())) + [0]
money = 1000
stock = 0
prev = 201
for i,price in enumerate(A):
if price > prev and money >= prev:
stock += money // prev
money -= stock * prev
elif price < prev and stock:
money += prev * stock
stock = 0
prev = pric... | [["+", 0, 7, 8, 196, 0, 57, 15, 679, 17, 355], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 20]] | 5 | 85 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using pll = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, l, r) for (ll i = (l); i <= (ll)(r); i++)
#define rep3(i, l, r) for... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using pll = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, l, r) for (ll i = (l); i <= (ll)(r); i++)
#define rep3(i, l, r) for... | [["+", 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 | 2,337 |
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int n;
int a[81];
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
long long int money = 1000;
long long int kabusuu = 0;
long long int maxmoney = 1000;
for (int i = 1; i < n; i++) {
if (kabusuu == 0) {
if (a... | #include <stdio.h>
#include <stdlib.h>
int main(void) {
int n;
int a[81];
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
long long int money = 1000;
long long int kabusuu = 0;
long long int maxmoney = 1000;
for (int i = 1; i < n; i++) {
if (kabusuu == 0) {
if (a... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 0 | 212 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)
using n... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)
using n... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 1 | 259 |
import java.util.*;
public class Main {
static int gcd(int a, int b) { return b > 0 ? gcd(b, a % b) : a; }
static long mod = 1000000007;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] A = new int[N];
int money = 1000;
int stock = 0;... | import java.util.*;
public class Main {
static int gcd(int a, int b) { return b > 0 ? gcd(b, a % b) : a; }
static long mod = 1000000007;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] A = new int[N];
long money = 1000;
long stock = ... | [["-", 0, 195, 8, 196, 0, 503, 39, 506, 0, 507], ["+", 0, 195, 8, 196, 0, 503, 39, 506, 0, 96], ["-", 0, 57, 64, 196, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 17, 107]] | 3 | 232 |
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
int main(void) {
int N;
int A[80];
long long money = 1000;
long long trade = 0;
scanf("%d", &N);
for (int i = 0; i < N; i++) {
scanf("%d", &A[i]);
}
for (int i = 0; i < N - 1; i++) {
if (A[i] < A[i + 1]) {
tra... | #include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
int main(void) {
int N;
int A[80];
long long money = 1000;
long long trade = 0;
scanf("%d", &N);
for (int i = 0; i < N; i++) {
scanf("%d", &A[i]);
}
for (int i = 0; i < N - 1; i++) {
if (A[i] < A[i + 1]) {
tra... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 0 | 179 |
n = int(input())
L = list(map(int,input().split()))
a = 1000
k = 0
for i in range(n-1):
if L[i]<L[i+1]:
k = a//L[i]
a = a-L[i]*k
elif L[i]>L[i+1] and k > 0:
a = a + L[i]*k
k = 0
else:
if k > 0:
a = a + L[n-1]*k
print(a)
| n = int(input())
L = list(map(int,input().split()))
a = 1000
k = 0
for i in range(n-1):
if L[i]<L[i+1] and k == 0:
k = a//L[i]
a = a-L[i]*k
elif L[i]>L[i+1] and k > 0:
a = a + L[i]*k
k = 0
else:
if k > 0:
a = a + L[n-1]*k
print(a)
| [["+", 0, 7, 8, 196, 0, 57, 15, 679, 17, 355], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 60], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 612]] | 5 | 125 |
n = int(input())
a = [300]
a += list(map(int,input().split()))
a += [0]
#print(a)
d = []
for i in range(1,len(a)-1):
if a[i-1] > a[i] <= a[i+1]:
d.append((a[i],-1))
elif a[i-1] < a[i] >= a[i+1]:
d.append((a[i],1))
m = 1000
k = 0
for x,y in d:
c = m//x
if y == -1:
k += c
m -= x*c
else:
m ... | n = int(input())
a = [300]
a += list(map(int,input().split()))
a += [0]
#print(a)
d = []
for i in range(1,len(a)-1):
if a[i-1] >= a[i] < a[i+1]:
d.append((a[i],-1))
elif a[i-1] <= a[i] > a[i+1]:
d.append((a[i],1))
m = 1000
k = 0
for x,y in d:
c = m//x
if y == -1:
k += c
m -= x*c
else:
m ... | [["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18], ["-", 8, 196, 0, 57, 75, 665, 15, 666, 667, 18], ["+", 8, 196, 0, 57, 75, 665, 15, 666, 667, 19], ["-", 8, 196, 0, 57, 75, 665, 15, 666... | 5 | 174 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
#define fi first
#define se second
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
co... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
#define fi first
#define se second
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
co... | [["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]] | 1 | 427 |
n = int(input())
a = list(map(int, input().split()))
m = 1000
s = 0
mx = [0] * n
for i in range(1, n):
if a[i-1] < a[i]:
mx[i] = 1
mx[i-1] = 0
mn = [0] * n
for i in range(1, n):
if a[i-1] > a[i]:
mn[i] = 1
mn[i-1] = 0
if a[0] < a[1]:
mn[0] = 1
mn[-1] ... | n = int(input())
a = list(map(int, input().split()))
m = 1000
s = 0
mx = [0] * n
for i in range(1, n):
if a[i-1] < a[i]:
mx[i] = 1
mx[i-1] = 0
mn = [0] * n
for i in range(1, n):
if a[i-1] >= a[i]:
mn[i] = 1
mn[i-1] = 0
if a[0] < a[1]:
mn[0] = 1
mn[-1]... | [["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20]] | 5 | 203 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll, ll>;
const ll mod = 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define REPS(i, n) for (ll(i) = 1; (i) <= (n); (i)++)
#define RREP(i, n) for (ll(i) = (n -... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll, ll>;
const ll mod = 1e9 + 7;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define REPS(i, n) for (ll(i) = 1; (i) <= (n); (i)++)
#define RREP(i, n) for (ll(i) = (n -... | [["-", 8, 9, 0, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 17, 107]] | 1 | 314 |
N = int(input())
A = list(map(int,input().split()))
money = 1000
kabu = 0
for i in range(N-1):
if A[i+1] <= A[i]:
money += A[i] * kabu
kabu = 0
else:
kabu = money//A[i]
money -= A[i] * (money//A[i])
#print(kabu,money)
money += A[-1] * kabu
print(money)
| N = int(input())
A = list(map(int,input().split()))
money = 1000
kabu = 0
for i in range(N-1):
if A[i+1] < A[i]:
money += A[i] * kabu
kabu = 0
else:
kabu += money//A[i]
money -= A[i] * (money//A[i])
#print(kabu,money)
money += A[-1] * kabu
print(money)
| [["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18], ["-", 75, 76, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 75, 76, 8, 196, 0, 1, 0, 677, 17, 107]] | 5 | 104 |
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def debug(k,v) puts "#{k}: #{v}" end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
n = gi #10**3
as = gsmi
now = 1000
kabu = 0
as.each_cons(2) ... | def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def debug(k,v) puts "#{k}: #{v}" end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
n = gi #10**3
as = gsmi
now = 1000
kabu = 0
as.each_cons(2) ... | [["+", 64, 749, 0, 662, 12, 762, 0, 738, 31, 22], ["+", 64, 749, 0, 662, 12, 762, 0, 738, 17, 72]] | 4 | 182 |
#include <algorithm> // count_ifに必要
#include <array> // sizeはコンパイル時定数で固定
#include <cmath>
#include <iomanip> // cout << setprecision(15) << x で小数の出力精度を指定
#include <iostream>
#include <map>
#include <numeric> // accumulate, gcd
#include <queue> // priority_queue も入ってる
#include <set> // 要素数は size() で取得 multiset... | #include <algorithm> // count_ifに必要
#include <array> // sizeはコンパイル時定数で固定
#include <cmath>
#include <iomanip> // cout << setprecision(15) << x で小数の出力精度を指定
#include <iostream>
#include <map>
#include <numeric> // accumulate, gcd
#include <queue> // priority_queue も入ってる
#include <set> // 要素数は size() で取得 multiset... | [["-", 0, 16, 12, 23, 0, 16, 31, 16, 17, 47], ["+", 0, 16, 12, 23, 0, 16, 31, 16, 17, 20], ["-", 0, 16, 12, 23, 0, 16, 12, 16, 17, 19], ["+", 0, 16, 12, 23, 0, 16, 12, 16, 17, 18], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 17, 18], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 17, 19], ["-", 0, 16, 31, 23, 0, 16, 12, 16, 17, 20], ["+"... | 1 | 425 |
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
#import numpy as np
import bisect
import sys
#import sympy
sys.setrecursionlimit(10**6)
def bfs(s, n, node):
# 頂点が探索済みかどうかのチェック配列
check = [Fa... | from collections import Counter
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
#import numpy as np
import bisect
import sys
#import sympy
sys.setrecursionlimit(10**6)
def bfs(s, n, node):
# 頂点が探索済みかどうかのチェック配列
check = [Fa... | [["-", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32]] | 5 | 331 |
<?php
list($n) = explode(" ", trim(fgets(STDIN)));
$a = array_map('intval', explode(" ", trim(fgets(STDIN))));
$isBuy = true;
$kabu = 0;
$money = 1000;
for ($i=0; $i<$n-1; $i++) {
if($isBuy && $a[$i+1] > $a[$i]){
// buy
$kabu = intdiv($money, $a[$i]);
if($kabu == 0){
continue;... | <?php
list($n) = explode(" ", trim(fgets(STDIN)));
$a = array_map('intval', explode(" ", trim(fgets(STDIN))));
$isBuy = true;
$kabu = 0;
$money = 1000;
for ($i=0; $i<$n-1; $i++) {
if($isBuy && $a[$i+1] > $a[$i]){
// buy
$kabu = intdiv($money, $a[$i]);
if($kabu == 0){
continue;... | [["+", 0, 493, 0, 57, 15, 23, 0, 616, 0, 111], ["-", 0, 57, 15, 23, 0, 16, 31, 606, 0, 141], ["-", 0, 493, 0, 57, 15, 23, 0, 16, 17, 79], ["-", 0, 493, 0, 57, 15, 23, 0, 16, 12, 612], ["+", 0, 57, 15, 23, 0, 616, 0, 606, 0, 141]] | 6 | 234 |
n=int(input())
a=list(map(int,input().split()))
ans=1000
for i in range(1,n):
if a[i]>a[i-1]:
ans += (a[i]-a[i-1])*(ans//a[i-1])
print(ans)
print(ans) | n=int(input())
a=list(map(int,input().split()))
ans=1000
for i in range(1,n):
if a[i]>a[i-1]:
ans += (a[i]-a[i-1])*(ans//a[i-1])
print(ans) | [["-", 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 | 85 |
n=int(input())
a=list(map(int,input().split()))
l=[]
for i in range(n-1):
if a[i+1]>a[i]:
l.append(1)
elif a[i+1]==a[i]:
l.append(0)
else:
l.append(-1)
m=1000
k=0
for i in range(n-1):
if l[i]==1:
p=m//a[i]
k+=p
m-=p*a[i]
if l[i]==-1:
m+=k*a[... | n=int(input())
a=list(map(int,input().split()))
l=[]
for i in range(n-1):
if a[i+1]>a[i]:
l.append(1)
elif a[i+1]==a[i]:
l.append(0)
else:
l.append(-1)
m=1000
k=0
for i in range(n-1):
if l[i]==1:
p=m//a[i]
k+=p
m-=p*a[i]
if l[i]==-1:
m+=k*a[... | [["-", 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, 21], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 169 |
def resolve():
n = int(input())
A = list(map(int, input().split()))
funds = 1000
stock = 0
for i in range(n):
if i > 0 and A[i] > A[i-1]:
# sell
funds += A[i] * stock
stock = 0
elif i < n-1 and A[i] < A[i+1]:
# buy
stock +=... | def resolve():
n = int(input())
A = list(map(int, input().split()))
funds = 1000
stock = 0
for i in range(n):
if i > 0 and A[i] > A[i-1]:
# sell
funds += A[i] * stock
stock = 0
if i < n-1 and A[i] < A[i+1]:
# buy
stock += f... | [["-", 0, 7, 8, 196, 0, 57, 75, 665, 0, 683], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121]] | 5 | 116 |
n = gets.to_i
nums = gets.split.map(&:to_i)
rest = 1000
stock = 0
waiting_to_buy = true
previous = nums.first
last_price = previous
nums[1..-1].each do |num|
if waiting_to_buy && num <= previous
previous = num
next
elsif waiting_to_buy
stock, rest = rest.divmod(previous)
previous = num
waiting_t... | n = gets.to_i
nums = gets.split.map(&:to_i)
rest = 1000
stock = 0
waiting_to_buy = true
previous = nums.first
last_price = previous
nums[1..-1].each do |num|
if waiting_to_buy && num <= previous
previous = num
next
elsif waiting_to_buy
stock, rest = rest.divmod(previous)
previous = num
waiting_t... | [["-", 75, 759, 75, 759, 64, 749, 0, 662, 0, 32], ["+", 75, 759, 75, 759, 64, 749, 0, 755, 17, 107]] | 4 | 123 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int N;
cin >> N;
vector<int> A;
int a;
cin >> a;
int pred = a;
A.push_back(a);
for (int i = 1; i < N; i++) {
cin >> a;
if (pred != a)
A.push_back(a);
pred = a;
}
if (A.size() == 1) {
cout << 1000 ... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int N;
cin >> N;
vector<int> A;
int a;
cin >> a;
int pred = a;
A.push_back(a);
for (int i = 1; i < N; i++) {
cin >> a;
if (pred != a)
A.push_back(a);
pred = a;
}
if (A.size() == 1) {
cout << 1000 ... | [["-", 0, 11, 12, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 11, 12, 16, 31, 16, 12, 69, 28, 22], ["-", 12, 16, 31, 23, 0, 16, 12, 69, 28, 22], ["+", 12, 16, 31, 23, 0, 16, 12, 69, 28, 22], ["-", 0, 11, 12, 16, 12, 16, 12, 69, 28, 22], ["+", 0, 11, 12, 16, 12, 16, 12, 69, 28, 22]] | 1 | 380 |
def main():
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().strip().split()]
i = 0
stock = 0
cash = 1000
while i+1 < N:
if A[i] < A[i+1]:
stock += cash // A[i]
cash -= stock * A[i]
... | def main():
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
N = int(input())
A = [int(x) for x in input().strip().split()]
i = 0
stock = 0
cash = 1000
while i+1 < N:
if A[i] < A[i+1] and stock == 0:
stock += cash // A[i]
cash -= stoc... | [["+", 0, 52, 8, 196, 0, 57, 15, 679, 17, 355], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 60], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 612]] | 5 | 151 |
#include <bits/stdc++.h>
#include <string.h>
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
using namespace std;
int nxt() {
int x;
cin >> x;
return x;
}
ll nxtl() {
ll x;
cin >> x;
return x;
}
void SieveOfEratosthenes(int n, vector<int> &primes) {
// Create a boolean array "prime[0.... | #include <bits/stdc++.h>
#include <string.h>
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
using namespace std;
int nxt() {
int x;
cin >> x;
return x;
}
ll nxtl() {
ll x;
cin >> x;
return x;
}
void SieveOfEratosthenes(int n, vector<int> &primes) {
// Create a boolean array "prime[0.... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 1 | 793 |
#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)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1 << (n))
using namespace std;
typedef long long ll;
typede... | #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)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1 << (n))
using namespace std;
typedef long long ll;
typede... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 64, 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,... | 1 | 349 |
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
n = int(input())
a = [int(x) for x in input().split()]
sold_day = set()
buy_day = set()
for i in range(1, n):
if a[i] > a[i - 1]:
sold_day.add(i)
buy_day.discard(i - 1)
money = 1000
stock = 0
sold_day = list(sold_day)
sold_day.sort(... | import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
n = int(input())
a = [int(x) for x in input().split()]
sold_day = set()
buy_day = set()
for i in range(1, n):
if a[i] > a[i - 1]:
sold_day.add(i)
sold_day.discard(i - 1)
money = 1000
stock = 0
sold_day = list(sold_day)
sold_day.sort... | [["-", 64, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 500, 22]] | 5 | 160 |
#pragma target("avx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9... | #pragma target("avx")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9... | [["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 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 | 592 |
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
N,=pin()
A=[*pin()]
mon=1000
stocks=0
fi... | #!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
N,=pin()
A=[*pin()]
mon=1000
stocks=0
fi... | [["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 20], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 47], ["-", 75, 665, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 75, 665, 64, 196, 0, 1, 0, 677, 17, 107], ["-", 3, 4, 0, 657, 12, 657, 31, 657, 31, 22], ["-", 3, 4, 0, 657, 12, 657, 31, 657, 17, 48]] | 5 | 193 |
n = int(input())
a = list(map(int, input().split()))
ans = 1000
stock = 0
for i, num in enumerate(a):
if i == n-1:
ans += stock*num
else:
if num > a[i+1]:
ans += stock*num
stock = 0
elif num < a[i+1]:
stock = ans//num
ans %= num
print(ans) | n = int(input())
a = list(map(int, input().split()))
ans = 1000
stock = 0
for i, num in enumerate(a):
if i == n-1:
ans += stock*num
else:
if num > a[i+1]:
ans += stock*num
stock = 0
elif num < a[i+1]:
stock += ans//num
ans %= num
else:
continue
print(ans) | [["-", 75, 665, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 75, 665, 64, 196, 0, 1, 0, 677, 17, 107], ["+", 75, 76, 8, 196, 0, 57, 75, 76, 0, 95], ["+", 75, 76, 8, 196, 0, 57, 75, 76, 0, 102], ["+", 0, 57, 75, 76, 8, 196, 0, 116, 0, 117]] | 5 | 95 |
n=int(input())
A=list(map(int,input().split()))
anow=0
anxt=0
m=1000
s=0
for i in range(n-1):
if A[i+1]>A[i]:
s=m//A[i]
m-=A[i]*(m//A[i])
elif A[i+1]<A[i]:
m+=A[i]*s
s=0
m+=A[n-1]*s
print(m) | n=int(input())
A=list(map(int,input().split()))
anow=0
anxt=0
m=1000
s=0
for i in range(n-1):
if A[i+1]>A[i]:
s+=m//A[i]
m-=A[i]*(m//A[i])
elif A[i+1]<A[i]:
m+=A[i]*s
s=0
m+=A[n-1]*s
print(m) | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]] | 5 | 121 |
N=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(N-1)]
for i in range(N-1):
if A[i]<A[i+1]:
B[i]=1
B=[0]+B
money=1000
tmp=0
up=[]
down=[]
for i in range(N-1):
if B[i]==0 and B[i+1]==1:
up.append(i)
if B[i]==1 and B[i+1]==0:
down.append(i)
if up:
if down==[]:
down.append(N-... | N=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(N-1)]
for i in range(N-1):
if A[i]<A[i+1]:
B[i]=1
B=[0]+B
money=1000
tmp=0
up=[]
down=[]
for i in range(N-1):
if B[i]==0 and B[i+1]==1:
up.append(i)
if B[i]==1 and B[i+1]==0:
down.append(i)
import bisect
if up:
if down==[]:
d... | [["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["-", 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]] | 5 | 251 |
N = int(input())
A = list(map(int, input().split()))
p = 1000
n = 0
for i in range(N-1):
if A[i+1] > A[i]:
n = p//A[i]
p = p % A[i]
if A[i+1] < A[i]:
p += n*A[i]
n = 0
p += n*A[-1]
print(p)
| N = int(input())
A = list(map(int, input().split()))
p = 1000
n = 0
for i in range(N-1):
if A[i+1] > A[i]:
n += p//A[i]
p = p % A[i]
if A[i+1] < A[i]:
p += n*A[i]
n = 0
p += n*A[-1]
print(p)
| [["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]] | 5 | 107 |
#include <bits/stdc++.h>
using namespace std;
// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {
Fast() {
std::cin.tie(0);
ios::sync_with_stdio(false);
}
} fast;
/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define AL... | #include <bits/stdc++.h>
using namespace std;
// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {
Fast() {
std::cin.tie(0);
ios::sync_with_stdio(false);
}
} fast;
/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define AL... | [["-", 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 | 927 |
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable : 4244) // 最悪をします
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include... | #define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable : 4244) // 最悪をします
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 1 | 11,018 |
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(), (a).end()
typedef pair<int, int> P;
typedef long long ll;
int main() {
int n;
... | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(), (a).end()
typedef pair<int, int> P;
typedef long long ll;
int main() {
int n;
... | [["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 265 |
n=int(input())
a=list(map(int,input().split()))
m=1000
k=0
peak=-1
for i in range(n-1):
if a[i]<a[i+1]:
peak=i+1
#print(peak)
for i in range(peak):
if a[i+1]>a[i]:
k=m//a[i]
m-=k*a[i]
# print(k,m)
elif a[i+1]<a[i]:
m+=k*a[i]
k=0
# print(k,m)
if peak!=-1:... | n=int(input())
a=list(map(int,input().split()))
m=1000
k=0
peak=-1
for i in range(n-1):
if a[i]<a[i+1]:
peak=i+1
for i in range(peak):
if a[i+1]>a[i] and k==0:
k=m//a[i]
m-=k*a[i]
# print(k,m,"rise")
elif a[i+1]<a[i]:
m+=k*a[i]
k=0
# print(k,m,"fall")
i... | [["+", 0, 7, 8, 196, 0, 57, 15, 679, 17, 355], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 60], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 0, 612]] | 5 | 149 |
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
up_trend = a[0] < a[1]
array = []
array << a[0] if (up_trend)
for i in 1...a.size do
if (up_trend)
if (a[i] < a[i-1])
array << a[i-1]
up_trend = false
end
else
if (a[i] > a[i-1])
array << a[i-1]
up_trend = true
end
... | n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)
up_trend = a[0] < a[1]
array = []
array << a[0] if (up_trend)
for i in 1...a.size do
if (up_trend)
if (a[i] < a[i-1])
array << a[i-1]
up_trend = false
end
else
if (a[i] > a[i-1])
array << a[i-1]
up_trend = true
end
... | [["+", 0, 493, 0, 121, 15, 739, 0, 738, 17, 98], ["+", 15, 739, 0, 738, 12, 738, 31, 742, 500, 22], ["+", 15, 739, 0, 738, 12, 738, 31, 742, 0, 70], ["+", 0, 738, 12, 738, 31, 742, 0, 748, 17, 33], ["+", 0, 738, 12, 738, 31, 742, 0, 748, 439, 612], ["+", 15, 739, 0, 738, 12, 738, 31, 742, 0, 73]] | 4 | 194 |
n = int(input(n))
a = list(map(int,input().split()))
yen = 1000
kabu = 0
for i in range(n-1):
if a[i] < a[i+1]:
kabu_today = yen // a[i]
kabu += kabu_today
yen = yen % a[i]
else:
yen += kabu * a[i]
kabu = 0
# print(yen, kabu,a[i], a[i] < a[i+1])
yen +... | n = int(input())
a = list(map(int,input().split()))
yen = 1000
kabu = 0
for i in range(n-1):
if a[i] < a[i+1]:
kabu_today = yen // a[i]
kabu += kabu_today
yen = yen % a[i]
else:
yen += kabu * a[i]
kabu = 0
# print(yen, kabu,a[i], a[i] < a[i+1])
yen +=... | [["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22]] | 5 | 105 |
#include <bits/stdc++.h>
using namespace std;
#define GO \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define int lon... | #include <bits/stdc++.h>
using namespace std;
#define GO \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define int lon... | [["+", 0, 57, 64, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]] | 1 | 158 |
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
long long inf = 1000000007;
long long modpow(long long n, long long p, long long mod);
int main() {
long long n;
cin >> n;
vector<long long> hoge(n);
for (long long i = 0; i < n; i++)
cin >> hoge.at(i);
long long money = 1000;
for (lo... | #include <bits/stdc++.h>
#include <math.h>
using namespace std;
long long inf = 1000000007;
long long modpow(long long n, long long p, long long mod);
int main() {
long long n;
cin >> n;
vector<long long> hoge(n);
for (long long i = 0; i < n; i++)
cin >> hoge.at(i);
long long money = 1000;
for (lo... | [["-", 0, 7, 8, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 7, 8, 9, 0, 1, 0, 27, 17, 29], ["-", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]] | 1 | 276 |
N = int(input())
A = list(map(int, input().split()))
M = 1000
stock = 0
for i in range(1, N):
# print(i)
if A[i-1] < A[i]:
stock += M // A[i-1]
M -= stock * A[i-1]
elif A[i-1] > A[i]:
M += stock * A[i-1]
stock = 0
M += stock * A[-1]
print(M) | N = int(input())
A = list(map(int, input().split()))
M = 1000
stock = 0
for i in range(1, N):
# print(i)
if A[i-1] < A[i]:
if stock == 0:
stock += M // A[i-1]
M -= stock * A[i-1]
elif A[i-1] > A[i]:
M += stock * A[i-1]
stock = 0
M += stock * A[-1]
print(M) | [["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 667, 60], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 612], ["+", 8, 196, 0, 57, 64, 196, 0, 57, 0, 102], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22]] | 5 | 114 |
def resolve():
n = int(input())
A = list(map(int, input().split()))
c = 1000
s = 0
for i in range(0, n-1):
j = i + 1 # 比較対象(翌日)
diff = A[j] - A[i]
# 次にup 今持っている現金を全て株にする
if diff > 0:
s = c // A[i]
c = c % A[i]
# 次にdown 今持っている株を全て現金にする... | def resolve():
n = int(input())
A = list(map(int, input().split()))
c = 1000
s = 0
for i in range(0, n-1):
j = i + 1 # 比較対象(翌日)
diff = A[j] - A[i]
# 次にup 今持っている現金を全て株にする
if diff > 0:
s += c // A[i]
c = c % A[i]
# 次にdown 今持っている株を全て現金にす... | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["-", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 75, 665, 0, 683]] | 5 | 130 |
n=int(input())
m=list(map(int,input().split()))
a=[]
if m[0]<m[1]:
a.append([0,-1])
for i in range(1,n-1):
if m[i]>m[i-1] and m[i]>=m[i+1]:
a.append([i,1])
elif m[i]<=m[i-1] and m[i]<m[i+1]:
a.append([i,-1])
elif m[i]<m[i-1] and m[i]<=m[i+1]:
a.append([i,-1])
elif m[i]<=m[i-1... | n=int(input())
m=list(map(int,input().split()))
a=[]
if m[0]<m[1]:
a.append([0,-1])
for i in range(1,n-1):
if m[i]>m[i-1] and m[i]>=m[i+1]:
a.append([i,1])
elif m[i]<=m[i-1] and m[i]<m[i+1]:
a.append([i,-1])
elif m[i]<m[i-1] and m[i]<=m[i+1]:
a.append([i,-1])
elif m[i]>=m[i-1... | [["-", 0, 57, 75, 665, 15, 679, 31, 666, 667, 19], ["+", 0, 57, 75, 665, 15, 679, 31, 666, 667, 20], ["-", 0, 57, 75, 665, 15, 679, 12, 666, 667, 18], ["+", 0, 57, 75, 665, 15, 679, 12, 666, 667, 47]] | 5 | 340 |
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int n, k;
vector<ll> a;
void input();
bool buy[100];
void solve() {
ll mx = 0;
ll money = 1000;
for (int i = 0; i < n - 1; i++) {
if (a[i] < a[i + 1]) {
int j = i + 1;
while (j < n - 1 && a[j - 1] < a[j]) {
... | #include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int n, k;
vector<ll> a;
void input();
bool buy[100];
void solve() {
ll mx = 0;
ll money = 1000;
for (int i = 0; i < n - 1; i++) {
if (a[i] < a[i + 1]) {
int j = i + 1;
while (j < n - 1 && a[j] <= a[j + 1]) {
... | [["-", 12, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["-", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 19], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 17, 72], ["+", 12, 16, 12, 69, 341, 342, 0, 16, 12, 13]] | 1 | 235 |
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]:
if money >= A[i]:
n = money // A[i]
stock += n
money -= A[i] * n
elif A[i+1] == A[i]:
continue
else:
if stock > 1:
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]:
if money >= A[i]:
n = money // A[i]
stock += n
money -= A[i] * n
elif A[i+1] == A[i]:
continue
else:
if stock > 1:
money... | [["-", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["+", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22]] | 5 | 131 |
n=int(input())
a=list(map(int,input().split()))
ans=1000
i=0
while i<n:
j=i
mi=a[i]
while j<n and mi>=a[j]:
mi=min(mi,a[j])
j+=1
if j==n:
break
stock=ans//mi
ans-=stock*mi
ans+=a[j]*stock
i=j+1
print(ans) | n=int(input())
a=list(map(int,input().split()))
ans=1000
i=0
while i<n:
j=i
mi=a[i]
while j<n and mi>=a[j]:
mi=min(mi,a[j])
j+=1
if j==n:
break
stock=ans//mi
ans-=stock*mi
ans+=a[j]*stock
i=j
print(ans) | [["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612]] | 5 | 104 |
import math
N = int(input())
A = list(map(int, input().split()))
C = 1
m = A[0]
M = A[0]
money = 1000;
for i in range(1,N):
if C == 1 and M <= A[i]:
M = A[i]
elif C == 1 and M > A[i]:
money = (money % m) + math.floor(money / m)*M
C = 0
m = A[i]
print(money)
elif C == 0 and m >= A[i]:
m = A... | import math
N = int(input())
A = list(map(int, input().split()))
C = 1
m = A[0]
M = A[0]
money = 1000;
for i in range(1,N):
if C == 1 and M <= A[i]:
M = A[i]
elif C == 1 and M > A[i]:
money = (money % m) + math.floor(money / m)*M
C = 0
m = A[i]
elif C == 0 and m >= A[i]:
m = A[i]
elif C == 0... | [["-", 75, 665, 64, 196, 0, 1, 0, 652, 63, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 183 |
// package com.company;
import java.io.*;
import java.lang.*;
import java.util.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
public static void main(String[] Args) throws Exception {
FastReader scan = ne... | // package com.company;
import java.io.*;
import java.lang.*;
import java.util.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
public static void main(String[] Args) throws Exception {
FastReader scan = ne... | [["-", 64, 196, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 64, 196, 0, 1, 0, 11, 12, 16, 12, 499]] | 3 | 639 |
n=int(input())
a=list(map(int,input().split()))
flag=0
b=[]
c=[]
for i in range(n-1):
if a[i]<a[i+1]:
if flag>0:
pass
else:
flag=1
b.append(a[i])
else:
if flag<=0:
pass
else:
flag=-1
c.append(a[i+1])
#pr... | n=int(input())
a=list(map(int,input().split()))
flag=0
b=[]
c=[]
for i in range(n-1):
if a[i]<a[i+1]:
if flag>0:
pass
else:
flag=1
b.append(a[i])
else:
if flag<=0:
pass
else:
flag=-1
c.append(a[i])
#prin... | [["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 72], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]] | 5 | 182 |
n = gets().chomp().to_i
prices = gets().chomp().split(' ').map(&:to_i)
curr_money = 1000
buy_at, count = -1, 0
while count < n do
if buy_at == -1
buy_at = count
else
if prices[buy_at] < prices[count]
curr_money += (curr_money / prices[buy_at]) * (prices[count] - prices[buy_at])
... | n = gets().chomp().to_i
prices = gets().chomp().split(' ').map(&:to_i)
curr_money = 1000
buy_at, count = -1, 0
while count < n do
if buy_at == -1
buy_at = count
else
if prices[buy_at] < prices[count]
curr_money += (curr_money / prices[buy_at]) * (prices[count] - prices[buy_at])
... | [["-", 0, 121, 64, 749, 0, 662, 12, 748, 17, 33], ["-", 0, 121, 64, 749, 0, 662, 12, 748, 439, 612], ["+", 75, 95, 0, 121, 64, 749, 0, 662, 12, 22]] | 4 | 106 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t n;
cin >> n;
int64_t y = 1000;
int64_t s = 0;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (a[0] < a[1]) {
s = y / a[0];
y -= a[0] * s;
}
for (int i = 1; i < n - 1; i++) {
if (a[i - 1] < a[i]) {
... | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t n;
cin >> n;
int64_t y = 1000;
int64_t s = 0;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (a[0] < a[1]) {
s = y / a[0];
y -= a[0] * s;
}
for (int i = 1; i < n - 1; i++) {
if (a[i - 1] < a[i]) {
... | [["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["-", 8, 9, 0, 57, 64, 9, 0, 116, 0, 35]] | 1 | 193 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------
int main() {
ll N;
cin >> N;
vect... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------
int main() {
ll N;
cin >> N;
vect... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 1 | 263 |
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define int long long
#define vi vector<int>
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
#define rep(i, b) for (int i = 0; i < b; i++)
#define repr(i, b) for (int i = b - 1; i >= 0; i--)
#define It(m... | #include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define int long long
#define vi vector<int>
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
#define rep(i, b) for (int i = 0; i < b; i++)
#define repr(i, b) for (int i = b - 1; i >= 0; i--)
#define It(m... | [["-", 75, 76, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 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 | 176 |
import numpy as np
def solve():
N = int(input())
A = list(map(int, input().split()))
A = np.int32(A)
D = np.diff(A)
if np.all(D <= 0):
return 1000
if np.all(D >= 0):
stock, money = divmod(1000, A[0])
money = stock * A[-1] + money
return money
money = 1000
... | import numpy as np
def solve():
N = int(input())
A = list(map(int, input().split()))
A = np.int32(A)
D = np.diff(A)
if np.all(D <= 0):
return 1000
if np.all(D >= 0):
stock, money = divmod(1000, A[0])
money = stock * A[-1] + money
return money
money = 1000
... | [["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612]] | 5 | 210 |
N = gets.to_i
A = gets.split.map(&:to_i)
stock = 0
ans = 1000
(N-1).times do |i|
if (A[i] < A[i+1])
stock = ans / A[i]
ans %= A[i]
elsif (A[i] > A[i+1])
ans += stock * A[i]
stock = 0
end
end
puts (ans + stock * A.last) | N = gets.to_i
A = gets.split.map(&:to_i)
stock = 0
ans = 1000
(N-1).times do |i|
if (A[i] < A[i+1] && stock == 0)
stock = ans / A[i]
ans %= A[i]
elsif (A[i] > A[i+1])
ans += stock * A[i]
stock = 0
end
end
puts (ans + stock * A.last) | [["+", 8, 736, 0, 121, 15, 739, 0, 738, 17, 98], ["+", 0, 121, 15, 739, 0, 738, 12, 738, 31, 22], ["+", 0, 121, 15, 739, 0, 738, 12, 738, 17, 60], ["+", 0, 121, 15, 739, 0, 738, 12, 738, 12, 612]] | 4 | 98 |
n = int(input())
a = list(map(int,input().split()))
hold = 0
money = 1000
for i in range(n-1):
if a[i+1] > a[i]:#buy
hold = money//a[i]
money = money % a[i]
elif a[i+1] < a[i]:#sell
money += hold*a[i]
hold = 0
print(money+a[n-1]*hold) | n = int(input())
a = list(map(int,input().split()))
hold = 0
money = 1000
for i in range(n-1):
if a[i+1] > a[i]:#buy
hold += money//a[i]
money = money % a[i]
elif a[i+1] < a[i]:#sell
money += hold*a[i]
hold = 0
print(money+a[n-1]*hold) | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]] | 5 | 109 |
days = int(input())
yen = 1000
prices = list(map(int, input().split()))
stocks = 0
for i in range(0, days-1):
if prices[i] < prices[i+1]:
stocks = yen // prices[i]
yen %= prices[i]
elif prices[i] > prices[i+1]:
yen += stocks*prices[i]
stocks = 0
yen += stocks*prices[days-1]
print(yen)
| days = int(input())
yen = 1000
prices = list(map(int, input().split()))
stocks = 0
for i in range(0, days-1):
if prices[i] < prices[i+1]:
stocks += yen // prices[i]
yen %= prices[i]
elif prices[i] > prices[i+1]:
yen += stocks*prices[i]
stocks = 0
yen += stocks*prices[days-1]
print(yen)
| [["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]] | 5 | 108 |
// Road to Millionaire
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i, x, y) for (ll i = x; i < y; i++)
#define nvarep(n, a) \
ll n; ... | // Road to Millionaire
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i, x, y) for (ll i = x; i < y; i++)
#define nvarep(n, a) \
ll n; ... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 1 | 281 |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = sc.nextInt();
long money = 1000;
long stock = 0;
for (int i = 0; i < n - 1; i++) {
... | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = sc.nextInt();
long money = 1000;
long stock = 0;
for (int i = 0; i < n - 1; i++) {
... | [["-", 0, 57, 64, 196, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 17, 107]] | 3 | 178 |
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007LL
#define all(x) x.begin(), x.end()
void solve() {
ll n;
cin >> n;
ll arr[n];
for (auto &x : arr)
cin >> x;
ll res = 1000, stocks = 0;
for (int i = 0; i < n; i++) {
if (i == 0) {
... | #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007LL
#define all(x) x.begin(), x.end()
void solve() {
ll n;
cin >> n;
ll arr[n];
for (auto &x : arr)
cin >> x;
ll res = 1000, stocks = 0;
for (int i = 0; i < n; i++) {
if (i == 0) {
... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 19], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18]] | 1 | 335 |
N = int(input())
A = [int(x) for x in input().split()]
genkin = 1000
kabu = 0
for i in range(N-1):
if A[i] < A[i+1]:
kabu = genkin // A[i]
genkin = genkin % A[i]
if A[i] > A[i+1]:
genkin += kabu * A[i]
kabu = 0
# print(genkin, kabu)
print(genkin + kabu * A[N-1]) | N = int(input())
A = [int(x) for x in input().split()]
genkin = 1000
kabu = 0
for i in range(N-1):
if A[i] < A[i+1]:
kabu += genkin // A[i]
genkin = genkin % A[i]
if A[i] > A[i+1]:
genkin += kabu * A[i]
kabu = 0
# print(genkin, kabu)
print(genkin + kabu * A[N-1]) | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]] | 5 | 109 |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using oset =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ull unsigned long long int
#define ll long... | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using oset =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ull unsigned long long int
#define ll long... | [["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 22]] | 1 | 375 |
n = int(input())
a = list(map(int, input().split()))
money =1000
stock = 0
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
print(money+stock*a[n-1])
| n = int(input())
a = list(map(int, input().split()))
money =1000
stock = 0
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
print(money+stock*a[n-1]) | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]] | 5 | 107 |
def main():
n = int(input())
inlis = list(map(int, input().split()))
kabu = 0
tmp = inlis[0]
shoji = 1000
for i in range(0, n-1):
if inlis[i] > tmp:
shoji += inlis[i] * kabu
tmp = inlis[i]
kabu = 0
#print(kabu, shoji)
if i... | def main():
n = int(input())
inlis = list(map(int, input().split()))
kabu = 0
tmp = inlis[0]
shoji = 1000
for i in range(0, n-1):
if inlis[i] > tmp:
shoji += inlis[i] * kabu
tmp = inlis[i]
kabu = 0
#print(i, inlis[i], kabu, shoji)
... | [["+", 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 | 190 |
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x, to) for (x = 0; x < (to); x++)
#define FORR(x, arr) for (auto &x : arr)
#define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define ALL(a) (a.begin()), ... | #include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x, to) for (x = 0; x < (to); x++)
#define FORR(x, arr) for (auto &x : arr)
#define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++)
#define ALL(a) (a.begin()), ... | [["+", 64, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]] | 1 | 338 |
N=int(input())
a=list(map(int,input().split()))
tmp=a[0]
up=0
check=0
stock=0
n=1000
for i in range(N-1):
if i==0:
if a[i]<=a[i+1]:
check=1
stock=n//a[i]
n-=stock*a[0]
else:
ckeck=2
else:
if check==1:
if a[i]<=a[i+1]:
... | N=int(input())
a=list(map(int,input().split()))
tmp=a[0]
up=0
check=0
stock=0
n=1000
for i in range(N-1):
if i==0:
if a[i]<=a[i+1]:
check=1
stock=n//a[i]
n-=stock*a[0]
else:
check=2
else:
if check==1:
if a[i]<=a[i+1]:
... | [["-", 75, 76, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 75, 76, 8, 196, 0, 1, 0, 662, 31, 22]] | 5 | 188 |
#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.at(i);
}
int16_t S = 1000;
for (int i = 0; i < N - 1; i++) {
if (A.at(i + 1) > A.at(i)) {
S = (S / A.at(i)) * A.at(i + 1) + S % A.at(i);
}
}
cout << S... | #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.at(i);
}
long long S = 1000;
for (int i = 0; i < N - 1; i++) {
if (A.at(i + 1) > A.at(i)) {
S = (S / A.at(i)) * A.at(i + 1) + S % A.at(i);
}
}
cout <<... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96]] | 1 | 136 |
n = gets.to_i
a = gets.split.map(&:to_i)
cash = 1000
stock = 0
0.upto(n-2){|i|
if a[i] < a[i+1]
stock = cash/a[i]
cash -= stock*a[i]
end
if a[i] > a[i+1]
cash += stock*a[i]
stock = 0
end
}
if stock!=0
cash += stock*a[n-1]
stock = 0
end
p cash
| n = gets.to_i
a = gets.split.map(&:to_i)
cash = 1000
stock = 0
0.upto(n-2){|i|
if a[i] < a[i+1] && stock == 0
stock = cash/a[i]
cash -= stock*a[i]
end
if a[i] > a[i+1]
cash += stock*a[i]
stock = 0
end
}
if stock!=0
cash += stock*a[n-1]
stock = 0
end
p cash
| [["+", 196, 196, 8, 734, 0, 121, 15, 738, 17, 98], ["+", 8, 734, 0, 121, 15, 738, 12, 738, 31, 22], ["+", 8, 734, 0, 121, 15, 738, 12, 738, 17, 60], ["+", 8, 734, 0, 121, 15, 738, 12, 738, 12, 612]] | 4 | 108 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
int n;
cin >> n;
int a[n];
ll start = 1000, stock = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < (n - 1); i++) {
if (a[i] < a[i + 1]) {
stock = start / a[i];
start = start % a[i];
... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
int n;
cin >> n;
int a[n];
ll start = 1000, stock = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < (n - 1); i++) {
if (a[i] < a[i + 1]) {
stock += start / a[i];
start = start % a[i];
... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 1 | 163 |
n = int(input())
a = list(map(int,input().split()))
a.append(0)
ans = 1000
cnt = 0
for i in range(n):
if a[i] < a[i+1]:
cnt = ans // a[i]
ans -= a[i] * cnt
else:
ans += a[i] * cnt
cnt = 0
print(ans)
| n = int(input())
a = list(map(int,input().split()))
a.append(0)
ans = 1000
cnt = 0
for i in range(n):
if a[i] < a[i+1]:
tmp = ans // a[i]
cnt += tmp
ans -= a[i] * tmp
else:
ans += a[i] * cnt
cnt = 0
print(ans)
| [["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 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], ["-", 64, 196, 0, 1, 0, 677, 12, 657, 12, 22], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 12, 22]] | 5 | 91 |
""" D
https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_d
"""
import sys
import math
from bisect import bisect_left
def readString():
return sys.stdin.readline()
def readInteger():
return int(readString())
def readStringSet(n):
return sys.stdin.readline().split(" ")[:n]
def readInteg... | """ D
https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_d
"""
import sys
import math
from bisect import bisect_left
def readString():
return sys.stdin.readline()
def readInteger():
return int(readString())
def readStringSet(n):
return sys.stdin.readline().split(" ")[:n]
def readInteg... | [["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]] | 5 | 284 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for (i = 0; i < (n); i++)
#define for1(n) for (i = 1; i <= (n); i++)
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll _, i, j, n, a, b, e, k, u, t, x = 1, m, y, q, f = 1, c = 0, d = 0, l, p, z,
... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define for0(n) for (i = 0; i < (n); i++)
#define for1(n) for (i = 1; i <= (n); i++)
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll _, i, j, n, a, b, e, k, u, t, x = 1, m, y, q, f = 1, c = 0, d = 0, l, p, z,
... | [["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["-", 64, 9, 0, 57, 64, 9, 0, 1, 0, 35]] | 1 | 230 |
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop ... | #include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop ... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 1 | 973 |
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout \
if (false) \
cout
#define debug()... | #include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout \
if (false) \
cout
#define debug()... | [["-", 64, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 64, 9, 0, 1, 0, 11, 12, 16, 12, 13]] | 1 | 298 |
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
bool check(int i, vector<int> &A) {
FOR(j, i + 1, A.size()) if (A[i] < A[j]) return true;
return false;
}
int main() ... | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
bool check(int i, vector<int> &A) {
FOR(j, i + 1, A.size()) if (A[i] < A[j]) return true;
return false;
}
int main() ... | [["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 20], ["-", 0, 52, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 19]] | 1 | 263 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(... | [["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]] | 1 | 469 |
n = int(input())
a = list(map(int,input().split()))
cash = 1000
stock = 0
for i in range(n-1):
if(a[i] > a[i+1]):
cash += stock * a[i]
stock = 0
elif(a[i] < a[i+1]):
stock += cash // a[i]
cash %= a[i]
print(cash,stock)
cash += stock * a[n-1]
print(cash)
| n = int(input())
a = list(map(int,input().split()))
cash = 1000
stock = 0
for i in range(n-1):
if(a[i] > a[i+1]):
cash += stock * a[i]
stock = 0
elif(a[i] < a[i+1]):
stock += cash // a[i]
cash %= a[i]
cash += stock * a[n-1]
print(cash)
| [["-", 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, 21], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 116 |
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ALL(x) begin(x), end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
template <class T> inline bool chmax(... | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i, a, b) for (int i = a; i <= (int)(b); i++)
#define ALL(x) begin(x), end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
template <class T> inline bool chmax(... | [["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]] | 1 | 365 |
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll, ll>
#define mll map<ll, ll>
#define pii pair<int, int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define All(x, v) for (auto x... | #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll, ll>
#define mll map<ll, ll>
#define pii pair<int, int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define All(x, v) for (auto x... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 20], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 19], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 19], ["-", 0, 57, 15, 339, 51, 16, 12, 16,... | 1 | 578 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.