problem_id stringlengths 6 6 | language stringclasses 2 values | original_status stringclasses 3 values | original_src stringlengths 19 243k | changed_src stringlengths 19 243k | change stringclasses 3 values | i1 int64 0 8.44k | i2 int64 0 8.44k | j1 int64 0 8.44k | j2 int64 0 8.44k | error stringclasses 270 values | stderr stringlengths 0 226k |
|---|---|---|---|---|---|---|---|---|---|---|---|
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
long long temp[1000], a[100000], n, m, ans;
inline void __merge(int l, int r) {
if (l == r)
return;
int mid = (l + r) >> 1;
__merge(l, mid);
__merge(mid + 1, r);
int i = l, j = mid + 1;
for (int k = l; k <= r; k++) {
if ((i <= mid && a[i] < a[j]) || j > r)
temp[k] = a[i++];
else
temp[k] = a[j++];
}
for (int k = l; k <= r; k++)
a[k] = temp[k];
}
int main() {
scanf("%lld%lld", &n, &m);
if (m >= n) {
puts("0");
return 0;
}
for (int i = 1; i <= n; i++)
scanf("%lld", &a[i]);
__merge(1, n);
for (int i = 1; i <= n - m; i++)
ans += a[i];
printf("%lld", ans);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
long long temp[200020], a[200020], n, m, ans;
inline void __merge(int l, int r) {
if (l == r)
return;
int mid = (l + r) >> 1;
__merge(l, mid);
__merge(mid + 1, r);
int i = l, j = mid + 1;
for (int k = l; k <= r; k++) {
if ((i <= mid && a[i] < a[j]) || j > r)
temp[k] = a[i++];
else
temp[k] = a[j++];
}
for (int k = l; k <= r; k++)
a[k] = temp[k];
}
int main() {
scanf("%lld%lld", &n, &m);
if (m >= n) {
puts("0");
return 0;
}
for (int i = 1; i <= n; i++)
scanf("%lld", &a[i]);
__merge(1, n);
for (int i = 1; i <= n - m; i++)
ans += a[i];
printf("%lld", ans);
return 0;
} | replace | 2 | 3 | 2 | 3 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
#define int long long
using namespace std;
int n, p[100005], k, ans = 0;
signed main() {
cin >> n >> k;
for (int i = 0; i < n; i++)
cin >> p[i];
sort(p, p + n);
for (int i = 0; i < n - k; i++) {
ans += p[i];
}
cout << ans;
return 0;
} | #include <bits/stdc++.h>
#define int long long
using namespace std;
int n, p[200005], k, ans = 0;
signed main() {
cin >> n >> k;
for (int i = 0; i < n; i++)
cin >> p[i];
sort(p, p + n);
for (int i = 0; i < n - k; i++) {
ans += p[i];
}
cout << ans;
return 0;
} | replace | 3 | 4 | 3 | 4 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> H(N);
for (int i = 0; i < N; i++)
cin >> H.at(i);
sort(H.rbegin(), H.rend());
for (int i = 0; i < K; i++)
H.at(i) = 0;
cout << accumulate(H.begin(), H.end(), 0L) << "\n";
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> H(N);
for (int i = 0; i < N; i++)
cin >> H.at(i);
sort(H.rbegin(), H.rend());
for (int i = 0; i < min(K, N); i++)
H.at(i) = 0;
cout << accumulate(H.begin(), H.end(), 0L) << "\n";
} | replace | 12 | 13 | 12 | 13 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
long long INF = LLONG_MAX;
ll a[100111];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
ll n, k;
cin >> n >> k;
ll sum = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (int i = 0; i < n - k; i++) {
sum += a[i];
}
cout << sum << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
long long INF = LLONG_MAX;
ll a[200222];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
ll n, k;
cin >> n >> k;
ll sum = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (int i = 0; i < n - k; i++) {
sum += a[i];
}
cout << sum << endl;
}
| replace | 20 | 21 | 20 | 21 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
int main() {
int n, k;
cin >> n >> k;
vector<int> h(n);
rep(i, n) cin >> h[i];
sort(h.rbegin(), h.rend());
ll ans = 0;
if (n <= k) {
ans = 0;
} else {
for (int i = n - 1; i > k; i++) {
ans += h[i];
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
int main() {
int n, k;
cin >> n >> k;
vector<int> h(n);
rep(i, n) cin >> h[i];
sort(h.rbegin(), h.rend());
ll ans = 0;
if (n <= k) {
ans = 0;
} else {
for (int i = n - 1; i >= k; i--) {
ans += h[i];
}
}
cout << ans << endl;
return 0;
} | replace | 15 | 16 | 15 | 16 | -11 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
#define int long long
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)a, i##_len = (b); i < i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(box) box.begin(), box.end()
using namespace std;
using P = pair<int, int>;
using ll = long long;
const long long INF = LLONG_MAX / 3;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
struct UnionFind {
std::vector<int> par, siz;
void init(int n) {
par.resize(n);
for (int i = 0; i < n; i++)
par[i] = i;
siz.resize(n, 1);
}
UnionFind(int n) { init(n); }
int root(int n) {
if (par[n] == n)
return n;
else
return par[n] = root(par[n]);
}
bool issame(int x, int y) { return (root(x) == root(y)); }
bool marge(int a, int b) {
if (issame(a, b))
return false;
else {
a = root(a), b = root(b);
if (siz[a] < siz[b])
swap(a, b);
siz[a] += siz[b];
par[a] = par[b];
return true;
}
}
int size(int n) { return siz[root(n)]; }
};
long long gcd(long long a, long long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
long long lcm(long long i, long long j) { return i * (j / gcd(i, j)); }
const int MOD = 1e9 + 7;
long long fac[510000], finv[510000], inv[510000];
long long MAX = 510000;
bool COMinited = false;
long long COM(int n, int k) {
if (COMinited == false) {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
COMinited = true;
}
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); }
signed main() {
int n, k;
cin >> n >> k;
int h[100010];
rep(i, n) cin >> h[i];
sort(h, h + n);
int s = 0;
rep(i, n - k) s += h[i];
cout << s << endl;
}
| #include <bits/stdc++.h>
#define int long long
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)a, i##_len = (b); i < i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(box) box.begin(), box.end()
using namespace std;
using P = pair<int, int>;
using ll = long long;
const long long INF = LLONG_MAX / 3;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
struct UnionFind {
std::vector<int> par, siz;
void init(int n) {
par.resize(n);
for (int i = 0; i < n; i++)
par[i] = i;
siz.resize(n, 1);
}
UnionFind(int n) { init(n); }
int root(int n) {
if (par[n] == n)
return n;
else
return par[n] = root(par[n]);
}
bool issame(int x, int y) { return (root(x) == root(y)); }
bool marge(int a, int b) {
if (issame(a, b))
return false;
else {
a = root(a), b = root(b);
if (siz[a] < siz[b])
swap(a, b);
siz[a] += siz[b];
par[a] = par[b];
return true;
}
}
int size(int n) { return siz[root(n)]; }
};
long long gcd(long long a, long long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
long long lcm(long long i, long long j) { return i * (j / gcd(i, j)); }
const int MOD = 1e9 + 7;
long long fac[510000], finv[510000], inv[510000];
long long MAX = 510000;
bool COMinited = false;
long long COM(int n, int k) {
if (COMinited == false) {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
COMinited = true;
}
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); }
signed main() {
int n, k;
cin >> n >> k;
int h[200010];
rep(i, n) cin >> h[i];
sort(h, h + n);
int s = 0;
rep(i, n - k) s += h[i];
cout << s << endl;
}
| replace | 107 | 108 | 107 | 108 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll i, j, k, n, m;
cin >> n >> m;
ll a[m];
ll sum = 0;
for (i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (i = 0; i < (n - m); i++)
sum += a[i];
cout << sum;
} | #include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll i, j, k, n, m;
cin >> n >> m;
ll a[n];
ll sum = 0;
for (i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (i = 0; i < (n - m); i++)
sum += a[i];
cout << sum;
} | replace | 9 | 10 | 9 | 10 | 0 | |
p02785 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(), (a).end()
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _fromto2(i, n) for (int i = 0; i <= (n); ++i)
#define _fromto3(i, a, b) for (int i = (a); i <= (b); ++i)
#define fromto(...) _overload3(__VA_ARGS__, _fromto3, _fromto2, )(__VA_ARGS__)
#define rrep(i, n) for (int i = (n); i >= 0; --i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++it)
const int MOD = 1e9 + 7;
const int INF = 1e9;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
// debug
template <class T> ostream &operator<<(ostream &os, vector<T> &vec) {
os << "{";
for (int i = 0; i < vec.size(); ++i)
os << (i ? ", " : "") << vec[i];
os << "}";
return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &rhs) {
out << "(" << rhs.first << ", " << rhs.second << ")";
return out;
}
#include <type_traits>
template <
typename T, size_t SIZE,
enable_if_t<!is_same<remove_cv_t<T>, char>::value, nullptr_t> = nullptr>
ostream &operator<<(ostream &os, T (&arr)[SIZE]) {
os << "{";
for (size_t i = 0; i < SIZE; ++i)
os << (i ? ", " : "") << arr[i];
os << "}";
return os;
}
#ifdef LOCAL
#define debug(v) cerr << v << "\n"
#else
#define debug(...) 42
#endif
int main() {
int N, K;
cin >> N >> K;
vi H(N);
rep(i, N) { cin >> H[i]; }
sort(H.begin(), H.end());
reverse(H.begin(), H.end());
rep(i, K) { H[i] = 0; }
ll ans = 0;
rep(i, N) ans += H[i];
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(), (a).end()
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _fromto2(i, n) for (int i = 0; i <= (n); ++i)
#define _fromto3(i, a, b) for (int i = (a); i <= (b); ++i)
#define fromto(...) _overload3(__VA_ARGS__, _fromto3, _fromto2, )(__VA_ARGS__)
#define rrep(i, n) for (int i = (n); i >= 0; --i)
#define iter(it, v) for (auto it = v.begin(); it != v.end(); ++it)
const int MOD = 1e9 + 7;
const int INF = 1e9;
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
// debug
template <class T> ostream &operator<<(ostream &os, vector<T> &vec) {
os << "{";
for (int i = 0; i < vec.size(); ++i)
os << (i ? ", " : "") << vec[i];
os << "}";
return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &rhs) {
out << "(" << rhs.first << ", " << rhs.second << ")";
return out;
}
#include <type_traits>
template <
typename T, size_t SIZE,
enable_if_t<!is_same<remove_cv_t<T>, char>::value, nullptr_t> = nullptr>
ostream &operator<<(ostream &os, T (&arr)[SIZE]) {
os << "{";
for (size_t i = 0; i < SIZE; ++i)
os << (i ? ", " : "") << arr[i];
os << "}";
return os;
}
#ifdef LOCAL
#define debug(v) cerr << v << "\n"
#else
#define debug(...) 42
#endif
int main() {
int N, K;
cin >> N >> K;
vi H(N);
rep(i, N) { cin >> H[i]; }
sort(H.begin(), H.end());
reverse(H.begin(), H.end());
rep(i, min(N, K)) { H[i] = 0; }
ll ans = 0;
rep(i, N) ans += H[i];
cout << ans << endl;
return 0;
}
| replace | 81 | 82 | 81 | 82 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> H(N);
for (int i = 0; i < N; i++)
cin >> H.at(i);
sort(H.rbegin(), H.rend());
cout << accumulate(H.begin() + K, H.end(), 0L) << "\n";
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> H(N);
for (int i = 0; i < N; i++)
cin >> H.at(i);
sort(H.rbegin(), H.rend());
K = min(N, K);
cout << accumulate(H.begin() + K, H.end(), 0L) << "\n";
} | insert | 10 | 10 | 10 | 11 | 0 | |
p02785 | Python | Time Limit Exceeded | import numpy as np
N, K = [int(i) for i in input().split()]
H = [int(h) for h in input().split()]
H = np.sort(np.array(H))[::-1]
for i in range(min(K, H.shape[0])):
H = np.delete(H, 0)
print(np.sum(H))
| import numpy as np
N, K = [int(i) for i in input().split()]
H = [int(h) for h in input().split()]
H = np.sort(np.array(H))[::-1]
H = H[min(K, H.shape[0]) :]
print(np.sum(H))
| replace | 6 | 8 | 6 | 7 | TLE | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main() {
fast;
ll n, k, cnt = 0;
cin >> n >> k;
vector<ll> arr(n);
for (auto i = 0; i < n; ++i)
cin >> arr[i];
sort(arr.begin(), arr.end(), greater<>());
for (auto i = 0; k; ++i) {
arr[i] = 0;
--k;
}
for (auto i = 0; i < n; ++i)
cnt += arr[i];
cout << cnt << '\n';
return 0;
}
ll strtoint(string str) {
ll x = 0;
stringstream ss;
ss << str;
ss >> x;
return x;
} | #include <bits/stdc++.h>
using namespace std;
#define fast \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main() {
fast;
ll n, k, cnt = 0;
cin >> n >> k;
vector<ll> arr(n);
for (auto i = 0; i < n; ++i)
cin >> arr[i];
sort(arr.begin(), arr.end(), greater<>());
for (auto i = 0; k && i < n; ++i) {
arr[i] = 0;
--k;
}
for (auto i = 0; i < n; ++i)
cnt += arr[i];
cout << cnt << '\n';
return 0;
}
ll strtoint(string str) {
ll x = 0;
stringstream ss;
ss << str;
ss >> x;
return x;
} | replace | 16 | 17 | 16 | 17 | 0 | |
p02785 | C++ | Runtime Error | #include "bits/stdc++.h"
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) \
sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define FORL(i, a, b) for (LL i = (a); i < (b); ++i)
#define REPL(i, n) FORL(i, 0, n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INT_LARGE = 1000000100;
// debug func
template <typename T> void vecprint(vector<T> v) {
for (auto x : v) {
cerr << x << " ";
}
cerr << endl;
}
template <typename T> void vecvecprint(vector<vector<T>> vv) {
REP(i, SIZE(vv)) {
REP(j, SIZE(vv[i])) { cerr << vv[i][j] << " "; }
cerr << endl;
}
}
template <typename T> void pqprint(priority_queue<T> q) {
while (!q.empty()) {
cerr << q.top() << " ";
q.pop();
}
cerr << endl;
}
template <typename T> void qprint(queue<T> q) {
while (!q.empty()) {
cerr << q.front() << " ";
q.pop();
}
cerr << endl;
}
template <typename T> void vecqprint(vector<queue<T>> v) {
for (int i = 0; i < v.size(); i++) {
qprint(v[i]);
}
}
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k,
const Iterator last) {
/* Credits: Thomas Draper */
if ((first == last) || (first == k) || (last == k))
return false;
Iterator itr1 = first;
Iterator itr2 = last;
++itr1;
if (last == itr1)
return false;
itr1 = last;
--itr1;
itr1 = k;
--itr2;
while (first != itr1) {
if (*--itr1 < *itr2) {
Iterator j = k;
while (!(*itr1 < *j))
++j;
iter_swap(itr1, j);
++itr1;
++j;
itr2 = k;
rotate(itr1, j, last);
while (last != j) {
++j;
++itr2;
}
rotate(k, itr2, last);
return true;
}
}
rotate(first, k, last);
return false;
}
inline double get_time_sec(void) {
return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(
chrono::steady_clock::now().time_since_epoch())
.count()) /
1000000000;
}
template <typename T> T gcd(T a, T b) {
if (a > b)
swap(a, b);
if (a == 0)
return b;
else
return gcd(b % a, a);
}
template <typename T> map<T, T> prime_list(T n) {
map<T, T> ret;
for (T i = 2; i * i <= n; i++) {
if (n % i == 0) {
ret[i] = 0;
while (n % i == 0) {
n /= i;
ret[i]++;
}
}
}
if (n != 1)
ret[n]++;
return ret;
}
int main(void) {
LL n, k;
cin >> n >> k;
VLL h(n);
REPL(i, n) cin >> h[i];
sort(ALL(h), greater<LL>());
// vecprint(h);
REPL(i, k) h[i] = 0;
// vecprint(h);
LL ans = 0;
REPL(i, n) ans += h[i];
cout << ans << endl;
} | #include "bits/stdc++.h"
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) \
sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define FORL(i, a, b) for (LL i = (a); i < (b); ++i)
#define REPL(i, n) FORL(i, 0, n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INT_LARGE = 1000000100;
// debug func
template <typename T> void vecprint(vector<T> v) {
for (auto x : v) {
cerr << x << " ";
}
cerr << endl;
}
template <typename T> void vecvecprint(vector<vector<T>> vv) {
REP(i, SIZE(vv)) {
REP(j, SIZE(vv[i])) { cerr << vv[i][j] << " "; }
cerr << endl;
}
}
template <typename T> void pqprint(priority_queue<T> q) {
while (!q.empty()) {
cerr << q.top() << " ";
q.pop();
}
cerr << endl;
}
template <typename T> void qprint(queue<T> q) {
while (!q.empty()) {
cerr << q.front() << " ";
q.pop();
}
cerr << endl;
}
template <typename T> void vecqprint(vector<queue<T>> v) {
for (int i = 0; i < v.size(); i++) {
qprint(v[i]);
}
}
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k,
const Iterator last) {
/* Credits: Thomas Draper */
if ((first == last) || (first == k) || (last == k))
return false;
Iterator itr1 = first;
Iterator itr2 = last;
++itr1;
if (last == itr1)
return false;
itr1 = last;
--itr1;
itr1 = k;
--itr2;
while (first != itr1) {
if (*--itr1 < *itr2) {
Iterator j = k;
while (!(*itr1 < *j))
++j;
iter_swap(itr1, j);
++itr1;
++j;
itr2 = k;
rotate(itr1, j, last);
while (last != j) {
++j;
++itr2;
}
rotate(k, itr2, last);
return true;
}
}
rotate(first, k, last);
return false;
}
inline double get_time_sec(void) {
return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(
chrono::steady_clock::now().time_since_epoch())
.count()) /
1000000000;
}
template <typename T> T gcd(T a, T b) {
if (a > b)
swap(a, b);
if (a == 0)
return b;
else
return gcd(b % a, a);
}
template <typename T> map<T, T> prime_list(T n) {
map<T, T> ret;
for (T i = 2; i * i <= n; i++) {
if (n % i == 0) {
ret[i] = 0;
while (n % i == 0) {
n /= i;
ret[i]++;
}
}
}
if (n != 1)
ret[n]++;
return ret;
}
int main(void) {
LL n, k;
cin >> n >> k;
k = min(n, k);
VLL h(n);
REPL(i, n) cin >> h[i];
sort(ALL(h), greater<LL>());
// vecprint(h);
REPL(i, k) h[i] = 0;
// vecprint(h);
LL ans = 0;
REPL(i, n) ans += h[i];
cout << ans << endl;
} | insert | 142 | 142 | 142 | 143 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, a, b) for (int i = int(a); i < (b); i++)
#define repr(i, b, a) for (int i = int(b); i >= (a); i--)
#define all(x) x.begin(), x.end()
const ll mod = 1e9 + 7;
const ll INF = 1e9;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
bool valid(int lx, int ux, int ly, int uy, int x, int y) {
return lx <= x && x < ux && ly <= y && y < uy;
}
ll power(ll x, ll p) {
if (p == 0)
return 1;
ll res = power(x * x % mod, p / 2);
if (p % 2 == 1)
res = res * x % mod;
return res;
}
int main() {
ll n, k;
cin >> n >> k;
vector<ll> h(n);
rep(i, n) cin >> h[i];
sort(all(h));
reverse(all(h));
rep(i, k) h[i] = 0;
cout << accumulate(all(h), 0LL) << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, a, b) for (int i = int(a); i < (b); i++)
#define repr(i, b, a) for (int i = int(b); i >= (a); i--)
#define all(x) x.begin(), x.end()
const ll mod = 1e9 + 7;
const ll INF = 1e9;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
bool valid(int lx, int ux, int ly, int uy, int x, int y) {
return lx <= x && x < ux && ly <= y && y < uy;
}
ll power(ll x, ll p) {
if (p == 0)
return 1;
ll res = power(x * x % mod, p / 2);
if (p % 2 == 1)
res = res * x % mod;
return res;
}
int main() {
ll n, k;
cin >> n >> k;
vector<ll> h(n);
rep(i, n) cin >> h[i];
sort(all(h));
reverse(all(h));
rep(i, min(n, k)) h[i] = 0;
cout << accumulate(all(h), 0LL) << endl;
return 0;
} | replace | 38 | 39 | 38 | 39 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long int
#define f first
#define s second
using namespace std;
void fast() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main() {
fast();
ll n, k;
cin >> n >> k;
vector<ll> v(n);
for (ll i = 0; i < n; i++)
cin >> v[i];
sort(v.begin(), v.end());
for (ll i = 0, j = n - 1; i < k; i++, j--) {
v[j] = 0;
}
ll ans = 0;
for (ll i = 0; i < n; i++)
ans += v[i];
cout << ans;
} | #include <bits/stdc++.h>
#define ll long long int
#define f first
#define s second
using namespace std;
void fast() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main() {
fast();
ll n, k;
cin >> n >> k;
vector<ll> v(n);
for (ll i = 0; i < n; i++)
cin >> v[i];
sort(v.begin(), v.end());
for (ll i = 0, j = n - 1; i < min(k, n); i++, j--) {
v[j] = 0;
}
ll ans = 0;
for (ll i = 0; i < n; i++)
ans += v[i];
cout << ans;
} | replace | 20 | 21 | 20 | 21 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int n, k, a[100001];
long long s;
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sort(a + 1, a + n + 1);
for (int i = 1; i <= n - k; i++) {
s += a[i];
}
cout << s;
}
| #include <bits/stdc++.h>
using namespace std;
int n, k, a[300001];
long long s;
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sort(a + 1, a + n + 1);
for (int i = 1; i <= n - k; i++) {
s += a[i];
}
cout << s;
}
| replace | 2 | 3 | 2 | 3 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<long> health(n);
for (int i = 0; i < n; i++) {
cin >> health[i];
}
sort(health.begin(), health.end(), greater<int>());
long long sum = 0LL;
if (k > 0)
health.erase(health.begin(), health.begin() + k);
for (int i = 0; i < health.size(); i++) {
sum += (long long)health[i];
}
cout << sum;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<long> health(n);
for (int i = 0; i < n; i++) {
cin >> health[i];
}
sort(health.begin(), health.end(), greater<int>());
long long sum = 0LL;
if (k > 0)
health.erase(health.begin(), health.begin() + min(k, n));
for (int i = 0; i < health.size(); i++) {
sum += (long long)health[i];
}
cout << sum;
return 0;
} | replace | 14 | 15 | 14 | 15 | 0 | |
p02785 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define rep(i, p) for (int i = 1; i <= p; i++)
#define ll long long
using namespace std;
int main() {
ll int N, K;
ll int kaisu;
kaisu = 0;
cin >> N >> K;
vector<ll int> H;
ll int x;
for (int i = 0; i < N; i++) {
cin >> x;
H.push_back(x);
kaisu += x;
}
sort(H.begin(), H.end(), greater<ll int>());
for (int i = 0; i < K; i++) {
kaisu -= H[i];
}
cout << kaisu;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define rep(i, p) for (int i = 1; i <= p; i++)
#define ll long long
using namespace std;
int main() {
ll int N, K;
ll int kaisu;
kaisu = 0;
cin >> N >> K;
vector<ll int> H;
ll int x;
for (int i = 0; i < N; i++) {
cin >> x;
H.push_back(x);
kaisu += x;
}
sort(H.begin(), H.end(), greater<ll int>());
for (int i = 0; i < K && i < N; i++) {
kaisu -= H[i];
}
cout << kaisu;
return 0;
}
| replace | 29 | 30 | 29 | 30 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
// #include "lib/bigint2.h"
#define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++)
#define rep(x, to) for (int(x) = 0; (x) < (to); (x)++)
#define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--)
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
const int MD = (int)1e9 + 7;
typedef vector<ll> VL;
void dbg() { cerr << "\n"; }
template <class T, class... T2> void dbg(const T &fst, const T2 &...rst) {
cerr << fst << ": ";
dbg(rst...);
}
template <class T> void amax(T &a, T b) {
if (a > b)
a = b;
}
int main() {
// cin.tie(0); ios_base::sync_with_stdio(false);
int n, k, ans = 0;
cin >> n >> k;
VL h(n);
rep(i, n) cin >> h[i];
sort(all(h));
rep(i, k) h[n - 1 - i] = 0;
ll sm = accumulate(all(h), 0LL);
cout << sm << "\n";
return 0;
}
| #include <bits/stdc++.h>
// #include "lib/bigint2.h"
#define rep2(x, fr, to) for (int(x) = (fr); (x) < (to); (x)++)
#define rep(x, to) for (int(x) = 0; (x) < (to); (x)++)
#define repr(x, fr, to) for (int(x) = (fr); (x) >= (to); (x)--)
#define all(c) (c).begin(), (c).end()
#define sz(v) (int)(v).size()
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
const int MD = (int)1e9 + 7;
typedef vector<ll> VL;
void dbg() { cerr << "\n"; }
template <class T, class... T2> void dbg(const T &fst, const T2 &...rst) {
cerr << fst << ": ";
dbg(rst...);
}
template <class T> void amax(T &a, T b) {
if (a > b)
a = b;
}
int main() {
// cin.tie(0); ios_base::sync_with_stdio(false);
int n, k, ans = 0;
cin >> n >> k;
VL h(n);
rep(i, n) cin >> h[i];
sort(all(h));
rep(i, k) if (n - 1 - i >= 0) h[n - 1 - i] = 0;
ll sm = accumulate(all(h), 0LL);
cout << sm << "\n";
return 0;
}
| replace | 33 | 34 | 33 | 34 | 0 | |
p02785 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main(void) {
int n, k, v;
long long num = 0;
vector<int> h;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> v;
h.push_back(v);
}
sort(h.begin(), h.end());
for (int i = h.size() - 1; k > 0; i--) {
h[i] = 0;
k--;
}
for (int i = 0; i < h.size(); i++) {
num += h[i];
}
cout << num << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main(void) {
int n, k, v;
long long num = 0;
vector<int> h;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> v;
h.push_back(v);
}
sort(h.begin(), h.end());
for (int i = 0; i < n - k; i++) {
num += h[i];
}
cout << num << endl;
return 0;
} | replace | 20 | 26 | 20 | 21 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
#define NREP() for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;
using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;
int main(int argc, char *argv[]) {
ll n, k;
cin >> n >> k;
ll h[n];
NREP() { cin >> h[i]; }
sort(h, h + n, greater<>());
REP(i, k) { h[i] = 0; }
ll ans = 0;
NREP() { ans += h[i]; }
MSG(ans)
}
| #include <bits/stdc++.h>
#define NREP() for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;
using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;
int main(int argc, char *argv[]) {
ll n, k;
cin >> n >> k;
ll h[n];
NREP() { cin >> h[i]; }
sort(h, h + n, greater<>());
REP(i, k) {
if (i >= n)
break;
h[i] = 0;
}
ll ans = 0;
NREP() { ans += h[i]; }
MSG(ans)
}
| replace | 21 | 22 | 21 | 26 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
auto s = 0LL;
vector<int> H(N);
for (auto &h : H) {
cin >> h;
s += h;
}
sort(H.rbegin(), H.rend());
for (int i = 0; i < K; ++i)
s -= H[i];
cout << s << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
auto s = 0LL;
vector<int> H(N);
for (auto &h : H) {
cin >> h;
s += h;
}
sort(H.rbegin(), H.rend());
for (int i = 0; i < min(K, N); ++i)
s -= H[i];
cout << s << endl;
} | replace | 12 | 13 | 12 | 13 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 7;
ll a[maxn];
int main() {
ll n, k, t, s = 0;
scanf("%lld%lld", &n, &k);
for (int i = 0; i < n; i++) {
scanf("%lld", &a[i]);
}
sort(a, a + n);
for (int i = 0; i < n - k; i++)
s += a[i];
printf("%lld\n", s);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 7;
ll a[maxn];
int main() {
ll n, k, t, s = 0;
scanf("%lld%lld", &n, &k);
for (int i = 0; i < n; i++) {
scanf("%lld", &a[i]);
}
sort(a, a + n);
for (int i = 0; i < n - k; i++)
s += a[i];
printf("%lld\n", s);
return 0;
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;
int main() {
int n, k;
cin >> n >> k;
vector<int> h(n);
rep(i, n) { cin >> h[i]; }
sort(h.begin(), h.end(), greater<int>());
rep(i, k) { h[i] = 0; }
llong atk = 0;
rep(i, n) { atk += h[i]; }
cout << atk << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;
int main() {
int n, k;
cin >> n >> k;
vector<int> h(n);
rep(i, n) { cin >> h[i]; }
sort(h.begin(), h.end(), greater<int>());
k = min(n, k);
rep(i, k) { h[i] = 0; }
llong atk = 0;
rep(i, n) { atk += h[i]; }
cout << atk << endl;
return 0;
} | insert | 14 | 14 | 14 | 15 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
int n, k;
cin >> n >> k;
vector<int> arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr.begin(), arr.end(), greater<int>());
cout << accumulate(arr.begin() + k, arr.end(), 0);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
int n, k;
cin >> n >> k;
vector<int> arr(n);
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
if (k >= n) {
cout << "0";
} else {
sort(arr.begin(), arr.end(), greater<int>());
cout << accumulate(arr.begin() + k, arr.end(), (int)0);
}
return 0;
} | replace | 13 | 16 | 13 | 19 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
ll n, m;
cin >> n >> m;
ll arr[100005] = {};
ll sum = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
sum += arr[i];
}
sort(arr, arr + n, greater<ll>());
for (int i = 0; i < m; i++) {
sum -= arr[i];
}
if (sum <= 0) {
cout << "0" << endl;
} else {
cout << sum << endl;
}
return 0;
}
| #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
ll n, m;
cin >> n >> m;
ll arr[300005] = {};
ll sum = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
sum += arr[i];
}
sort(arr, arr + n, greater<ll>());
for (int i = 0; i < m; i++) {
sum -= arr[i];
}
if (sum <= 0) {
cout << "0" << endl;
} else {
cout << sum << endl;
}
return 0;
}
| replace | 7 | 8 | 7 | 8 | 0 | |
p02785 | Python | Time Limit Exceeded | N, K = map(int, input().lower().split())
H = []
total = 0
input_string = input()
H = input_string.split()
H = list(map(int, H))
for j in range(K):
if not H:
break
else:
H.remove(max(H))
print(sum(H))
| N, K = map(int, input().lower().split())
H = []
total = 0
input_string = input()
H = input_string.split()
H = list(map(int, H))
H.sort(reverse=True)
del H[0:K]
print(sum(H))
| replace | 6 | 11 | 6 | 10 | TLE | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<long long> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.rbegin(), a.rend());
long long ans = 0;
for (int i = 0; i < k; i++) {
a[i] = 0;
}
for (int i = 0; i < n; i++) {
ans += a[i];
}
cout << ans << '\n';
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<long long> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.rbegin(), a.rend());
long long ans = 0;
for (int i = k; i < n; i++) {
ans += a[i];
}
cout << ans << '\n';
return 0;
} | replace | 15 | 19 | 15 | 16 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
int main() {
int n, k;
cin >> n >> k;
vector<ll> h(n);
rep(i, n) cin >> h[i];
bool ok[n];
rep(i, n) ok[i] = false;
sort(all(h));
reverse(all(h));
rep(i, k) { ok[i] = true; }
ll ans = 0;
rep(i, n) {
if (!ok[i]) {
ans += h[i];
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
int main() {
int n, k;
cin >> n >> k;
vector<ll> h(n);
rep(i, n) cin >> h[i];
bool ok[n];
rep(i, n) ok[i] = false;
sort(all(h));
reverse(all(h));
rep(i, min(k, n)) { ok[i] = true; }
ll ans = 0;
rep(i, n) {
if (!ok[i]) {
ans += h[i];
}
}
cout << ans << endl;
} | replace | 17 | 18 | 17 | 18 | 0 | |
p02785 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#define MAX_COUNT 200005
#define LL long long
using namespace std;
LL health[MAX_COUNT] = {0};
int partition(int start, int end) {
int p = start;
LL pivot = health[end];
for (int j = start; j < end; ++j) {
if (health[j] < pivot) {
LL t = health[j];
health[j] = health[p];
health[p] = t;
p++;
}
}
health[end] = health[p];
health[p] = pivot;
return p;
}
void quicksort(int start, int end) {
if (start < end) {
LL p = partition(start, end);
quicksort(start, p - 1);
quicksort(p + 1, end);
}
}
int main(int argc, char const *argv[]) {
int count, specials;
cin >> count >> specials;
LL res = 0;
for (int i = 0; i < count; ++i) {
cin >> health[i];
}
if (count <= specials) {
cout << 0;
goto end;
}
quicksort(0, count - 1);
for (int i = 0; i < count - specials; ++i)
res += health[i];
cout << res;
end:
return 0;
} | #include <algorithm>
#include <iostream>
#define MAX_COUNT 200005
#define LL long long
using namespace std;
LL health[MAX_COUNT] = {0};
int partition(int start, int end) {
int p = start;
LL pivot = health[end];
for (int j = start; j < end; ++j) {
if (health[j] < pivot) {
LL t = health[j];
health[j] = health[p];
health[p] = t;
p++;
}
}
health[end] = health[p];
health[p] = pivot;
return p;
}
void quicksort(int start, int end) {
if (start < end) {
LL p = partition(start, end);
quicksort(start, p - 1);
quicksort(p + 1, end);
}
}
int main(int argc, char const *argv[]) {
int count, specials;
cin >> count >> specials;
LL res = 0;
for (int i = 0; i < count; ++i) {
cin >> health[i];
}
if (count <= specials) {
cout << 0;
goto end;
}
if (specials == 0) {
for (int i = 0; i < count; ++i) {
res += health[i];
}
cout << res;
goto end;
}
quicksort(0, count - 1);
for (int i = 0; i < count - specials; ++i)
res += health[i];
cout << res;
end:
return 0;
} | insert | 42 | 42 | 42 | 49 | TLE | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t N, K;
cin >> N >> K;
vector<int> H(N);
for (int64_t i = 0; i < N; i++) {
int64_t j;
cin >> j;
H.at(i) = j;
}
sort(H.begin(), H.end());
for (int64_t i = 0; i < K; i++) {
H.pop_back();
}
int64_t h_sum = 0;
for (auto x : H) {
h_sum += x;
}
cout << h_sum << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t N, K;
cin >> N >> K;
vector<int> H(N);
for (int64_t i = 0; i < N; i++) {
int64_t j;
cin >> j;
H.at(i) = j;
}
sort(H.begin(), H.end());
for (int64_t i = 0; i < K; i++) {
H.pop_back();
if (H.size() == 0) {
break;
}
}
int64_t h_sum = 0;
for (auto x : H) {
h_sum += x;
}
cout << h_sum << endl;
} | insert | 20 | 20 | 20 | 23 | 0 | |
p02785 | C++ | Runtime Error | #include <algorithm>
#include <cstdio>
using namespace std;
int main(void) {
int n, k, i, j, h[20000], cnt;
long long sum;
scanf("%d %d", &n, &k);
for (i = 0; i < n; i++) {
scanf("%d", &h[i]);
}
sort(h, h + n);
cnt = k;
sum = 0;
for (i = n - 1; i >= 0; i--) {
if (cnt <= 0) {
sum += h[i];
} else {
cnt--;
}
}
printf("%lld\n", sum);
return 0;
}
| #include <algorithm>
#include <cstdio>
using namespace std;
int main(void) {
int n, k, i, j, h[200000], cnt;
long long sum;
scanf("%d %d", &n, &k);
for (i = 0; i < n; i++) {
scanf("%d", &h[i]);
}
sort(h, h + n);
cnt = k;
sum = 0;
for (i = n - 1; i >= 0; i--) {
if (cnt <= 0) {
sum += h[i];
} else {
cnt--;
}
}
printf("%lld\n", sum);
return 0;
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
vector<long long> h(n);
for (auto &e : h)
cin >> e;
sort(h.begin(), h.end());
long long res;
if (n == k) {
res = 0;
} else {
res = accumulate(begin(h), end(h) - k, 0LL);
}
cout << res << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
vector<long long> h(n);
for (auto &e : h)
cin >> e;
sort(h.begin(), h.end());
long long res;
if (n <= k) {
res = 0;
} else {
res = accumulate(begin(h), end(h) - k, 0LL);
}
cout << res << endl;
return 0;
} | replace | 11 | 12 | 11 | 12 | 0 | |
p02785 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
int n, k;
cin >> n >> k;
vector<ll> h(n);
rep(i, n) cin >> h[i];
sort(h.begin(), h.end(), greater<ll>());
ll sum = 0;
if (n <= k) {
cout << 0 << endl;
return 0;
}
for (int i = k; k < n; i++) {
sum += h[i];
}
cout << sum << endl;
}
// なぜ? | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
int n, k;
cin >> n >> k;
vector<ll> h(n);
rep(i, n) cin >> h[i];
sort(h.begin(), h.end(), greater<ll>());
ll sum = 0;
if (n <= k) {
cout << 0 << endl;
return 0;
}
for (int i = k; i < n; i++) {
sum += h[i];
}
cout << sum << endl;
}
// なぜ? | replace | 18 | 19 | 18 | 19 | TLE | |
p02785 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
int main() {
int n, k;
cin >> n >> k;
vector<int> h(n);
ll sum = 0;
rep(i, n) {
cin >> h[i];
sum += h[i];
}
sort(h.begin(), h.end());
rep(i, k) { sum -= h[n - i - 1]; }
if (sum < 0)
sum = 0;
cout << sum << endl;
return 0;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <random>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
int main() {
int n, k;
cin >> n >> k;
vector<int> h(n);
ll sum = 0;
rep(i, n) {
cin >> h[i];
sum += h[i];
}
sort(h.begin(), h.end());
rep(i, min(k, n)) { sum -= h[n - i - 1]; }
if (sum < 0)
sum = 0;
cout << sum << endl;
return 0;
} | replace | 23 | 24 | 23 | 24 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for (int i = (int)(a); (i) < (int)(n); ++(i))
#define repe(i, a, n) for (int i = (int)(a); (i) <= (int)(n); ++(i))
#define repif(i, a, x) for (int i = (int)(a); (x); ++(i))
#define repr(i, a, n) for (int i = ((int)(a)-1); (i) >= (int)(n); --(i))
#define reper(i, a, n) for (int i = (int)(a); (i) >= (int)(n); --(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x) / gcd(x, y) * (y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template <typename T, template <typename> typename C = less>
using PQ = priority_queue<T, vector<T>, C<T>>;
template <typename T> bool chmax(T &a, const T &b, bool t = false) {
if (a < b or (t and a == b)) {
a = b;
return true;
}
return false;
}
template <typename T> bool chmin(T &a, const T &b, bool t = false) {
if (a > b or (t and a == b)) {
a = b;
return true;
}
return false;
}
int N, K;
int H[100010];
signed main() {
cin >> N >> K;
rep(i, 0, N) cin >> H[i];
sort(H, H + N, greater<int>());
int ans = 0;
rep(i, K, N) ans += H[i];
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for (int i = (int)(a); (i) < (int)(n); ++(i))
#define repe(i, a, n) for (int i = (int)(a); (i) <= (int)(n); ++(i))
#define repif(i, a, x) for (int i = (int)(a); (x); ++(i))
#define repr(i, a, n) for (int i = ((int)(a)-1); (i) >= (int)(n); --(i))
#define reper(i, a, n) for (int i = (int)(a); (i) >= (int)(n); --(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x) / gcd(x, y) * (y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template <typename T, template <typename> typename C = less>
using PQ = priority_queue<T, vector<T>, C<T>>;
template <typename T> bool chmax(T &a, const T &b, bool t = false) {
if (a < b or (t and a == b)) {
a = b;
return true;
}
return false;
}
template <typename T> bool chmin(T &a, const T &b, bool t = false) {
if (a > b or (t and a == b)) {
a = b;
return true;
}
return false;
}
int N, K;
int H[200010];
signed main() {
cin >> N >> K;
rep(i, 0, N) cin >> H[i];
sort(H, H + N, greater<int>());
int ans = 0;
rep(i, K, N) ans += H[i];
cout << ans << endl;
return 0;
}
| replace | 52 | 53 | 52 | 53 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int h;
int n;
int sum = 0;
int a[100000];
int k;
int ans;
cin >> n;
cin >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
if (k >= n) {
ans = 0;
} else {
for (int i = 0; i < n - k; i++) {
ans += a[i];
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long int h, n, sum = 0, a[200000], k, ans = 0;
cin >> n;
cin >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
if (k >= n) {
ans = 0;
} else {
for (int i = 0; i < n - k; i++) {
ans += a[i];
}
}
cout << ans << endl;
return 0;
} | replace | 4 | 10 | 4 | 5 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll n, k;
cin >> n >> k;
vector<ll> v;
ll sum = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
v.push_back(x);
sum += x;
}
sort(v.rbegin(), v.rend());
for (int i = 0; i < k; i++) {
sum -= v[i];
}
cout << sum << "\n";
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ll n, k;
cin >> n >> k;
vector<ll> v;
ll sum = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
v.push_back(x);
sum += x;
}
sort(v.rbegin(), v.rend());
for (int i = 0; i < v.size(); i++) {
if (i >= k)
break;
sum -= v[i];
}
cout << sum << "\n";
return 0;
} | replace | 15 | 16 | 15 | 18 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;
const int N = 1e5 + 10;
ll a[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sort(a + 1, a + n + 1);
reverse(a + 1, a + n + 1);
ll ans = 0;
for (int i = k + 1; i <= n; i++) {
ans += a[i];
}
cout << ans << "\n";
#ifdef LOCAL
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;
const int N = 2e5 + 10;
ll a[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sort(a + 1, a + n + 1);
reverse(a + 1, a + n + 1);
ll ans = 0;
for (int i = k + 1; i <= n; i++) {
ans += a[i];
}
cout << ans << "\n";
#ifdef LOCAL
cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
return 0;
}
| replace | 9 | 10 | 9 | 10 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repr(i, n) for (int(i) = (n); (i) > 0; (i)--)
#define rrep(i, n, m) for (int(i) = (n); (i) < (m); (i)++)
#define rrepr(i, n, m) for (int(i) = (n); (i) > (m); (i)--)
#define SORT(s) sort((s).begin(), (s).end())
#define SORTR(s, t) sort((s).begin(), (s).end(), greater<t>())
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;
const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;
const ll MOD = 1000000007ll;
const int MAX = 510000;
int N, K;
vll H;
void input() {
cin >> N >> K;
rep(i, N) {
ll a;
cin >> a;
H.emplace_back(a);
}
return;
}
void solve() {
SORTR(H, ll);
rep(i, K) H[i] = 0ll;
ll ans = 0ll;
rep(i, N) ans += H[i];
cout << ans << endl;
return;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
input();
solve();
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define repr(i, n) for (int(i) = (n); (i) > 0; (i)--)
#define rrep(i, n, m) for (int(i) = (n); (i) < (m); (i)++)
#define rrepr(i, n, m) for (int(i) = (n); (i) > (m); (i)--)
#define SORT(s) sort((s).begin(), (s).end())
#define SORTR(s, t) sort((s).begin(), (s).end(), greater<t>())
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;
const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;
const ll MOD = 1000000007ll;
const int MAX = 510000;
int N, K;
vll H;
void input() {
cin >> N >> K;
rep(i, N) {
ll a;
cin >> a;
H.emplace_back(a);
}
return;
}
void solve() {
SORTR(H, ll);
rep(i, min(N, K)) H[i] = 0ll;
ll ans = 0ll;
rep(i, N) ans += H[i];
cout << ans << endl;
return;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
input();
solve();
return 0;
} | replace | 39 | 40 | 39 | 40 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n, k, h[100010];
long long ans = 0;
cin >> n >> k;
for (int i = 0; i < n; i++)
cin >> h[i];
sort(h, h + n);
for (int i = 0; i < n - k; i++) {
ans += h[i];
}
cout << ans;
}
| #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n, k, h[200010];
long long ans = 0;
cin >> n >> k;
for (int i = 0; i < n; i++)
cin >> h[i];
sort(h, h + n);
for (int i = 0; i < n - k; i++) {
ans += h[i];
}
cout << ans;
}
| replace | 3 | 4 | 3 | 4 | 0 | |
p02785 | C++ | Runtime Error | // ===================================
// author: M_sea
// website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#define re register
using namespace std;
typedef long long ll;
inline int read() {
int X = 0, w = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
w = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
X = X * 10 + c - '0', c = getchar();
return X * w;
}
int a[100010];
int main() {
int n = read(), k = min(n, read());
for (re int i = 1; i <= n; ++i)
a[i] = read();
sort(a + 1, a + n + 1);
reverse(a + 1, a + n + 1);
ll ans = 0;
for (re int i = k + 1; i <= n; ++i)
ans += a[i];
printf("%lld\n", ans);
return 0;
}
| // ===================================
// author: M_sea
// website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#define re register
using namespace std;
typedef long long ll;
inline int read() {
int X = 0, w = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
w = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
X = X * 10 + c - '0', c = getchar();
return X * w;
}
int a[200010];
int main() {
int n = read(), k = min(n, read());
for (re int i = 1; i <= n; ++i)
a[i] = read();
sort(a + 1, a + n + 1);
reverse(a + 1, a + n + 1);
ll ans = 0;
for (re int i = k + 1; i <= n; ++i)
ans += a[i];
printf("%lld\n", ans);
return 0;
}
| replace | 28 | 29 | 28 | 29 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
vector<int> h(n);
rep(i, n) cin >> h[i];
sort(h.begin(), h.end());
rep(i, k) h.pop_back();
long long ans = 0;
rep(i, h.size()) ans += h[i];
cout << ans << '\n';
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
vector<int> h(n);
rep(i, n) cin >> h[i];
sort(h.begin(), h.end());
if (n > k)
rep(i, k) h.pop_back();
else {
cout << 0 << '\n';
return 0;
}
long long ans = 0;
rep(i, h.size()) ans += h[i];
cout << ans << '\n';
return 0;
} | replace | 13 | 14 | 13 | 19 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vc = vector<char>;
using vb = vector<bool>;
using vl = vector<ll>;
#define rep(i, x, n) for (int i = x; i < n; i++)
#define all(x) x.begin(), x.end()
int main() {
ll n, k, sum = 0;
cin >> n >> k;
vl h(n);
rep(i, 0, n) { cin >> h[i]; }
sort(h.begin(), h.end());
for (int i = 0; i < k; i++) {
h[n - 1 - i] = 0;
}
for (int i = 0; i < n; i++) {
sum += h[i];
}
cout << sum;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vc = vector<char>;
using vb = vector<bool>;
using vl = vector<ll>;
#define rep(i, x, n) for (int i = x; i < n; i++)
#define all(x) x.begin(), x.end()
int main() {
ll n, k, sum = 0;
cin >> n >> k;
vl h(n);
rep(i, 0, n) { cin >> h[i]; }
sort(h.begin(), h.end());
for (int i = 0; i < k && i < n; i++) {
h[n - 1 - i] = 0;
}
for (int i = 0; i < n; i++) {
sum += h[i];
}
cout << sum;
}
| replace | 19 | 20 | 19 | 20 | 0 | |
p02785 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 100000;
int n, m, a[N + 9];
LL ans;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i)
scanf("%d", &a[i]);
sort(a + 1, a + n + 1);
for (int i = n - m; i >= 1; --i)
ans += a[i];
printf("%lld\n", ans);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 200000;
int n, m, a[N + 9];
LL ans;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i)
scanf("%d", &a[i]);
sort(a + 1, a + n + 1);
for (int i = n - m; i >= 1; --i)
ans += a[i];
printf("%lld\n", ans);
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02785 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
long T = 0;
cin >> N >> K;
vector<long> H(N);
for (int i = 0; i < N; i++)
cin >> H.at(i);
if (N < K)
K = N;
for (int i = 0; i < K; i++) {
for (int j = 0; j < N - 1 - i; j++) {
if (H.at(j) > H.at(j + 1))
swap(H.at(j), H.at(j + 1));
}
}
for (int i = 0; i < N - K; i++) {
T += H.at(i);
}
cout << T << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
long T = 0;
cin >> N >> K;
vector<long> H(N);
for (int i = 0; i < N; i++)
cin >> H.at(i);
if (N < K)
K = N;
sort(H.begin(), H.end());
for (int i = 0; i < N - K; i++) {
T += H.at(i);
}
cout << T << endl;
} | replace | 15 | 21 | 15 | 16 | TLE | |
p02785 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
void solve() {}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<int> h(n);
rep(i, n) { cin >> h[i]; }
sort(h.begin(), h.end(), greater<int>());
rep(i, k) { h[i] = 0; }
ll sum = 0;
rep(i, n) sum += h[i];
cout << sum;
return 0;
} | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
void solve() {}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<int> h(n);
rep(i, n) { cin >> h[i]; }
sort(h.begin(), h.end(), greater<int>());
rep(i, min(n, k)) { h[i] = 0; }
ll sum = 0;
rep(i, n) sum += h[i];
cout << sum;
return 0;
} | replace | 24 | 25 | 24 | 26 | 0 | |
p02785 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main(void) {
long long N, K;
cin >> N >> K;
vector<long long> vec(N);
for (int i = 0; i < N; ++i)
cin >> vec[i];
sort(vec.begin(), vec.end(), greater<int>());
for (int i = 0; i < K; ++i) {
vec[i] = 0;
}
long long tmp = 0;
for (auto i : vec)
tmp += i;
cout << tmp << "\n";
}
| #include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main(void) {
long long N, K;
cin >> N >> K;
vector<long long> vec(N);
for (int i = 0; i < N; ++i)
cin >> vec[i];
sort(vec.begin(), vec.end(), greater<int>());
for (int i = 0; i < K; ++i) {
if (i >= N)
break;
vec[i] = 0;
}
long long tmp = 0;
for (auto i : vec)
tmp += i;
cout << tmp << "\n";
}
| insert | 19 | 19 | 19 | 21 | 0 | |
p02785 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
using namespace std;
int a[200000];
int main() {
int n, k, M = -1, ti, i;
long long s = 0;
cin >> n >> k;
for (i = 0; i < n; i++) {
cin >> a[i];
s += a[i];
}
sort(a, a + n);
for (i = 1; i <= k; i++)
s -= a[n - i];
cout << s;
return 0;
} | #include <algorithm>
#include <iostream>
using namespace std;
int a[200000];
int main() {
int n, k, M = -1, ti, i;
long long s = 0;
cin >> n >> k;
for (i = 0; i < n; i++) {
cin >> a[i];
s += a[i];
}
if (n <= k) {
cout << "0";
return 0;
}
sort(a, a + n);
for (i = 1; i <= k; i++)
s -= a[n - i];
cout << s;
return 0;
} | insert | 12 | 12 | 12 | 16 | 0 | |
p02786 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t h = 0, c = 1;
cin >> h;
cout << flush;
if (h <= 1)
return 1;
while (h > 1) {
h /= 2;
++c;
}
int64_t ans = 0, d = 1;
for (int i = 0; i < c; ++i) {
ans += d;
d *= 2;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t h = 0, c = 1;
cin >> h;
while (h > 1) {
h /= 2;
++c;
}
int64_t ans = 0, d = 1;
for (int i = 0; i < c; ++i) {
ans += d;
d *= 2;
}
cout << ans << endl;
return 0;
}
| delete | 6 | 10 | 6 | 6 | 0 | |
p02786 | C++ | Time Limit Exceeded | // abc153_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define REPN(i, m, n) for (int(i) = m; (i) < (int)(n); ++(i))
#define REP_REV(i, n) for (int(i) = (int)(n)-1; (i) >= 0; --(i))
#define REPN_REV(i, m, n) for (int(i) = (int)(n)-1; (i) >= m; --(i))
#define ALL(x) x.begin(), x.end()
#define INF ((1 << 29) - 1)
#define MOD (1000000007)
#define print2D(h, w, arr) \
REP(i, h) { \
REP(j, w) cout << arr[i][j] << " "; \
cout << endl; \
}
#define print_line(vec, n) \
{ \
for (int i = 0; i < (n - 1); i++) \
cout << (vec)[i] << " "; \
cout << (vec)[(n)-1] << endl; \
}
template <class T> void print(const T &x) { cout << x << endl; }
template <class T, class... A> void print(const T &first, const A &...rest) {
cout << first << " ";
print(rest...);
}
struct PreMain {
PreMain() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
}
} premain;
int main() {
#ifdef LOCAL
ifstream in("../arg.txt");
cin.rdbuf(in.rdbuf());
#endif
ll H;
cin >> H;
ll cnt = 1;
ll ans = 0;
ll cur = H;
while (true) {
ans += cnt;
cur /= 2;
cnt *= 2;
if (cur == 1) {
ans += cnt;
break;
}
}
print(ans);
return 0;
}
| // abc153_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define REPN(i, m, n) for (int(i) = m; (i) < (int)(n); ++(i))
#define REP_REV(i, n) for (int(i) = (int)(n)-1; (i) >= 0; --(i))
#define REPN_REV(i, m, n) for (int(i) = (int)(n)-1; (i) >= m; --(i))
#define ALL(x) x.begin(), x.end()
#define INF ((1 << 29) - 1)
#define MOD (1000000007)
#define print2D(h, w, arr) \
REP(i, h) { \
REP(j, w) cout << arr[i][j] << " "; \
cout << endl; \
}
#define print_line(vec, n) \
{ \
for (int i = 0; i < (n - 1); i++) \
cout << (vec)[i] << " "; \
cout << (vec)[(n)-1] << endl; \
}
template <class T> void print(const T &x) { cout << x << endl; }
template <class T, class... A> void print(const T &first, const A &...rest) {
cout << first << " ";
print(rest...);
}
struct PreMain {
PreMain() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
}
} premain;
int main() {
#ifdef LOCAL
ifstream in("../arg.txt");
cin.rdbuf(in.rdbuf());
#endif
ll H;
cin >> H;
ll cnt = 1;
ll ans = 0;
ll cur = H;
if (H == 1) {
print(1);
return 0;
}
while (true) {
ans += cnt;
cur /= 2;
cnt *= 2;
if (cur == 1) {
ans += cnt;
break;
}
}
print(ans);
return 0;
}
| insert | 56 | 56 | 56 | 62 | TLE | |
p02786 | C++ | Runtime Error | /* FAILING IS AN ART
AND
I HAVE MASTERED IT
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define ff first
#define ss second
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define pb push_back
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;
ll bin_exp(ll a, ll b) {
ll ans = 1;
if (a == 0)
ans = 1;
while (b > 0) {
if (b & 1)
ans *= a;
a *= a;
b >>= 1;
}
return ans;
}
ll fun(ll x) {
if (x == 1)
return 1;
if (x % 2)
x--;
return 1 + 2 * fun(x / 2);
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
fast;
ll h;
cin >> h;
if (h == 1) {
cout << 1 << endl;
return 0;
}
else if (h == 2 or h == 3) {
cout << 3 << endl;
}
else {
cout << fun(h) << endl;
}
} | /* FAILING IS AN ART
AND
I HAVE MASTERED IT
*/
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long
#define ff first
#define ss second
#define fast \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define pb push_back
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;
ll bin_exp(ll a, ll b) {
ll ans = 1;
if (a == 0)
ans = 1;
while (b > 0) {
if (b & 1)
ans *= a;
a *= a;
b >>= 1;
}
return ans;
}
ll fun(ll x) {
if (x == 1)
return 1;
if (x % 2)
x--;
return 1 + 2 * fun(x / 2);
}
int main() {
fast;
ll h;
cin >> h;
if (h == 1) {
cout << 1 << endl;
return 0;
}
else if (h == 2 or h == 3) {
cout << 3 << endl;
}
else {
cout << fun(h) << endl;
}
} | delete | 45 | 49 | 45 | 45 | 0 | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define int long long
int minimumCost(int price[], int n) {
sort(price, price + n);
int totalCost = 0;
for (int i = n - 1; i > 1; i -= 2) {
if (i == 2) {
totalCost += price[2] + price[0];
} else {
int price_first = price[i] + price[0] + 2 * price[1];
int price_second = price[i] + price[i - 1] + 2 * price[0];
totalCost += min(price_first, price_second);
}
}
if (n == 1) {
totalCost += price[0];
} else {
totalCost += price[1];
}
return totalCost;
}
int func(int a) { return 1 + 2 * func(a / 2); }
int32_t main() {
int h;
cin >> h;
cout << func(h);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
int minimumCost(int price[], int n) {
sort(price, price + n);
int totalCost = 0;
for (int i = n - 1; i > 1; i -= 2) {
if (i == 2) {
totalCost += price[2] + price[0];
} else {
int price_first = price[i] + price[0] + 2 * price[1];
int price_second = price[i] + price[i - 1] + 2 * price[0];
totalCost += min(price_first, price_second);
}
}
if (n == 1) {
totalCost += price[0];
} else {
totalCost += price[1];
}
return totalCost;
}
int func(int a) {
if (a == 0)
return 0;
return 1 + 2 * func(a / 2);
}
int32_t main() {
int h;
cin >> h;
cout << func(h);
return 0;
}
| replace | 23 | 24 | 23 | 28 | TLE | |
p02786 | C++ | Time Limit Exceeded | // #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>
using namespace std;
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
typedef int64_t ll;
#define endl '\n'
#define int ll
ll mod = 1e9 + 7;
ll mod1 = 1e9 + 5;
ll power(ll a, ll b) {
if (b == 0)
return 1;
else if (b % 2 == 0)
return power((((a % mod) * (a % mod)) % mod), b / 2) % mod;
else
return ((a % mod) * (power((((a % mod) * (a % mod)) % mod), b / 2) % mod)) %
mod;
}
// using namespace __gnu_pbds;
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>,
// rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set
int32_t main() {
IOS
int h;
cin >> h;
multiset<int> m;
m.insert(h);
map<int, int> m1;
int ans = 0;
m1[h]++;
while (1) {
if (m.size() == 0)
break;
int x = *m.rbegin();
if (m.find(x) != m.end())
m.erase(m.find(x));
ans += m1[x];
if ((x / 2) == 1) {
ans += 2 * m1[x];
continue;
} else {
int te = x;
x /= 2;
m.insert(x);
m1[x] += 2 * m1[te];
}
}
cout << ans << endl;
}
| // #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>
using namespace std;
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
typedef int64_t ll;
#define endl '\n'
#define int ll
ll mod = 1e9 + 7;
ll mod1 = 1e9 + 5;
ll power(ll a, ll b) {
if (b == 0)
return 1;
else if (b % 2 == 0)
return power((((a % mod) * (a % mod)) % mod), b / 2) % mod;
else
return ((a % mod) * (power((((a % mod) * (a % mod)) % mod), b / 2) % mod)) %
mod;
}
// using namespace __gnu_pbds;
// #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>,
// rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set
int32_t main() {
IOS
int h;
cin >> h;
if (h == 1) {
cout << 1;
return 0;
}
multiset<int> m;
m.insert(h);
map<int, int> m1;
int ans = 0;
m1[h]++;
while (1) {
if (m.size() == 0)
break;
int x = *m.rbegin();
if (m.find(x) != m.end())
m.erase(m.find(x));
ans += m1[x];
if ((x / 2) == 1) {
ans += 2 * m1[x];
continue;
} else {
int te = x;
x /= 2;
m.insert(x);
m1[x] += 2 * m1[te];
}
}
cout << ans << endl;
}
| insert | 58 | 58 | 58 | 62 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll const mod = (ll)1e12;
#define max 1000
ll mons(ll h) {
int i = 1;
ll ans = 0;
while (i <= h) {
ans += i;
i = i * 2;
}
return ans;
}
int main() {
ll h;
cin >> h;
ll ans = mons(h);
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll const mod = (ll)1e12;
#define max 1000
ll mons(ll h) {
ll i = 1;
ll ans = 0;
while (i <= h) {
ans += i;
i = i * 2;
}
return ans;
}
int main() {
ll h;
cin >> h;
ll ans = mons(h);
cout << ans;
return 0;
} | replace | 8 | 9 | 8 | 9 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
int main() {
ll H;
cin >> H;
queue<ll> q;
q.push(H);
ll s = 0LL;
while (!q.empty()) {
ll h = q.front();
q.pop();
s += 1;
if (h > 1) {
q.push(h / 2);
q.push(h / 2);
}
}
cout << s << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
int main() {
ll H;
cin >> H;
ll i = 0LL, s = 0LL;
while (H > 0LL) {
s += pow(2LL, i++);
H = H / 2LL;
}
cout << s << endl;
return 0;
} | replace | 33 | 45 | 33 | 37 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair<int, int>
#define all(vv) (vv).begin(), (vv).end()
#define rep(ii, jj, ll, ss) for (int ii = jj; ii < ll; ii += ss)
#define time \
cerr << '\n' << (double)clock() / CLOCKS_PER_SEC << '\n'; \
return 0;
int h, ans;
int foo(int n) {
if (n == 1)
return 1;
return 1 + foo(n / 2) + foo(n / 2);
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> h;
ans = foo(h);
cout << ans;
time
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair<int, int>
#define all(vv) (vv).begin(), (vv).end()
#define rep(ii, jj, ll, ss) for (int ii = jj; ii < ll; ii += ss)
#define time \
cerr << '\n' << (double)clock() / CLOCKS_PER_SEC << '\n'; \
return 0;
int h, ans;
int foo(int n) {
if (n == 1)
return 1;
return 1 + 2 * foo(n / 2);
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> h;
ans = foo(h);
cout << ans;
time
} | replace | 16 | 17 | 16 | 17 | TLE | |
p02786 | C++ | Time Limit Exceeded | /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author Sagor
*/
#include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <vector>
typedef long long int ll;
typedef double ld;
using namespace std;
class DCaracalVsMonster {
public:
void solve(std::istream &in, std::ostream &out) {
ll n, i, step = 0;
in >> n;
for (i = 0;; i++) {
ll po = 1 << i;
if (po > n) {
break;
}
if (po <= n) {
step += po;
}
}
out << step << endl;
}
};
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
DCaracalVsMonster solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return 0;
}
| /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author Sagor
*/
#include <algorithm>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <set>
#include <vector>
typedef long long int ll;
typedef double ld;
using namespace std;
class DCaracalVsMonster {
public:
void solve(std::istream &in, std::ostream &out) {
ll n, i, step = 0;
in >> n;
for (i = 0;; i++) {
ll po = 1LL << i;
if (po > n) {
break;
}
if (po <= n) {
step += po;
}
}
out << step << endl;
}
};
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
DCaracalVsMonster solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return 0;
}
| replace | 25 | 26 | 25 | 26 | TLE | |
p02786 | C++ | Runtime Error |
#include <bits/stdc++.h>
#define MOD 1000000007
#define debug(x) cout << "x :" << x << endl;
#define case(t, ans) cout << "Case #" << t << ": " << ans << endl;
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ll long long
// typedef long long ll;
// typedef vector<int> vi;
// typedef pair<int,int> pi;
using namespace std;
void solve();
ll cal(ll n) {
if (n == 1)
return 1;
return (2 * cal(n / 2) + 1);
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// int t;
// cin>>t;
// while(t--)
solve();
return 0;
}
void solve() {
ll h;
cin >> h;
cout << cal(h) << endl;
}
|
#include <bits/stdc++.h>
#define MOD 1000000007
#define debug(x) cout << "x :" << x << endl;
#define case(t, ans) cout << "Case #" << t << ": " << ans << endl;
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ll long long
// typedef long long ll;
// typedef vector<int> vi;
// typedef pair<int,int> pi;
using namespace std;
void solve();
ll cal(ll n) {
if (n == 1)
return 1;
return (2 * cal(n / 2) + 1);
}
int main() {
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// int t;
// cin>>t;
// while(t--)
solve();
return 0;
}
void solve() {
ll h;
cin >> h;
cout << cal(h) << endl;
}
| replace | 25 | 29 | 25 | 29 | 0 | |
p02786 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
using namespace std;
template <typename T> inline string to_bin_str(T n) {
string str;
while (n > 0) {
str.push_back('0' + (n & 1));
n >>= 1;
}
reverse(str.begin(), str.end());
return str;
}
int main() {
long long H;
cin >> H;
string bin = to_bin_str(H);
for (int i = 0; i < bin.length(); i++) {
if (bin[i] == '0') {
bin[i] = '1';
}
}
int ans = stoi(bin, 0, 2);
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
using namespace std;
template <typename T> inline string to_bin_str(T n) {
string str;
while (n > 0) {
str.push_back('0' + (n & 1));
n >>= 1;
}
reverse(str.begin(), str.end());
return str;
}
int main() {
long long H;
cin >> H;
string bin = to_bin_str(H);
for (int i = 0; i < bin.length(); i++) {
if (bin[i] == '0') {
bin[i] = '1';
}
}
long long ans = stol(bin, 0, 2);
cout << ans << endl;
return 0;
} | replace | 30 | 31 | 30 | 31 | 0 | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int64_t attack(int64_t hp) {
if (hp == 1) {
return 1;
}
return 1 + attack(hp / 2) + attack(hp / 2);
}
int main() {
int64_t h, min;
cin >> h;
min = attack(h);
cout << min << endl;
} | #include <bits/stdc++.h>
using namespace std;
int64_t attack(int64_t hp) {
if (hp == 1) {
return 1;
}
return 1 + 2 * attack(hp / 2);
}
int main() {
int64_t h, min;
cin >> h;
min = attack(h);
cout << min << endl;
} | replace | 7 | 8 | 7 | 8 | TLE | |
p02786 | C++ | Runtime Error | #define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"
using namespace std;
const long long MOD = (long long)1e9 + 7;
long long h;
int fun(long long v) {
int ret = 2 * fun(v / 2);
if (v % 2)
ret++;
return ret;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> h;
cout << fun(h) << E;
// system("pause");
return 0;
} | #define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"
using namespace std;
const long long MOD = (long long)1e9 + 7;
long long h;
long long fun(long long v) {
if (v == 1)
return 1;
long long ret = 2 * fun(v / 2);
ret++;
return ret;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> h;
cout << fun(h) << E;
// system("pause");
return 0;
} | replace | 12 | 16 | 12 | 17 | -11 | |
p02786 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>
typedef long long ll;
#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T binarysearch(vector<T> A, T key) {
ll left = 0;
ll right = 4;
ll mid;
while (left < right) {
mid = (left + right) / 2;
if (key == A[mid])
return 1;
if (key > A[mid])
left = mid + 1;
else if (key < A[mid])
right = mid;
}
return 0;
}
template <typename T> T finder(vector<T> vec, T number) {
auto itr = find(vec.begin(), vec.end(), number);
size_t index = distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
ll frac(ll n) // 階乗
{
if (n == 0) {
return 1;
}
return (n * frac(n - 1)) % MOD;
}
template <typename T> T keta(T a) {
ll kazu = 1;
while (1) {
if (a / 10 != 0) {
a /= 10;
kazu++;
} else
break;
}
return kazu;
} // 桁数
template <typename T> T nCr(ll n, T r) {
ll ans = 1;
for (int i = n; i > n - r; --i) {
ans = ans * i;
}
for (int i = 1; i < r + 1; ++i) {
ans = ans / i;
}
return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
yaju[i] = r[i] - '0';
}
*///map < string, ll> s;
/*if (N % 2 != 0)a = N / 2;
else a = N / 2 - 1;
for (int i = 1;i <= a;i++) {
for (int j = 0;j < N - (i * 2);j++) {
if (S[j] != S[j + i] && S[j + i * 2] != S[j] && S[j + i] != S[j
+ i * 2]) sum--; if (sum == 0)break;
}
}*/
int main() {
ll H, a;
cin >> H;
ll ans = 1;
ll mon = 1;
while (1) {
H = H / 2;
mon *= 2;
ans += mon;
if (H == 1)
break;
}
cout << ans << endl;
} | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <unordered_map>
#include <vector>
typedef long long ll;
#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T binarysearch(vector<T> A, T key) {
ll left = 0;
ll right = 4;
ll mid;
while (left < right) {
mid = (left + right) / 2;
if (key == A[mid])
return 1;
if (key > A[mid])
left = mid + 1;
else if (key < A[mid])
right = mid;
}
return 0;
}
template <typename T> T finder(vector<T> vec, T number) {
auto itr = find(vec.begin(), vec.end(), number);
size_t index = distance(vec.begin(), itr);
if (index != vec.size()) { // 発見できたとき
return 1;
} else { // 発見できなかったとき
return 0;
}
}
ll frac(ll n) // 階乗
{
if (n == 0) {
return 1;
}
return (n * frac(n - 1)) % MOD;
}
template <typename T> T keta(T a) {
ll kazu = 1;
while (1) {
if (a / 10 != 0) {
a /= 10;
kazu++;
} else
break;
}
return kazu;
} // 桁数
template <typename T> T nCr(ll n, T r) {
ll ans = 1;
for (int i = n; i > n - r; --i) {
ans = ans * i;
}
for (int i = 1; i < r + 1; ++i) {
ans = ans / i;
}
return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
yaju[i] = r[i] - '0';
}
*///map < string, ll> s;
/*if (N % 2 != 0)a = N / 2;
else a = N / 2 - 1;
for (int i = 1;i <= a;i++) {
for (int j = 0;j < N - (i * 2);j++) {
if (S[j] != S[j + i] && S[j + i * 2] != S[j] && S[j + i] != S[j
+ i * 2]) sum--; if (sum == 0)break;
}
}*/
int main() {
ll H, a;
cin >> H;
ll ans = 1;
ll mon = 1;
if (H == 1)
ans = 1;
else {
while (1) {
H = H / 2;
mon *= 2;
ans += mon;
if (H == 1)
break;
}
}
cout << ans << endl;
} | replace | 106 | 112 | 106 | 116 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = int(a); i <= int(b); ++i)
using namespace std;
template <class A> void pr(A a) { cout << (a) << endl; }
template <class A, class B> void pr(A a, B b) {
cout << a << " ";
pr(b);
}
template <class A, class B, class C> void pr(A a, B b, C c) {
cout << a << " ";
pr(b, c);
}
template <class A, class B, class C, class D> void pr(A a, B b, C c, D d) {
cout << a << " ";
pr(b, c, d);
}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF = numeric_limits<int>::max();
// for(int j=0;j<N;++j) {
ll atack_cnt(ll H) {
if (H < 2) {
return 1;
}
return atack_cnt(H / 2) + atack_cnt(H / 2) + 1;
}
int main(void) {
ll H;
cin >> H;
// ll res=0;
pr(atack_cnt(H));
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, a, b) for (int i = int(a); i <= int(b); ++i)
using namespace std;
template <class A> void pr(A a) { cout << (a) << endl; }
template <class A, class B> void pr(A a, B b) {
cout << a << " ";
pr(b);
}
template <class A, class B, class C> void pr(A a, B b, C c) {
cout << a << " ";
pr(b, c);
}
template <class A, class B, class C, class D> void pr(A a, B b, C c, D d) {
cout << a << " ";
pr(b, c, d);
}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF = numeric_limits<int>::max();
// for(int j=0;j<N;++j) {
ll atack_cnt(ll H) {
if (H < 2) {
return 1;
}
return atack_cnt(H / 2) * 2 + 1;
}
int main(void) {
ll H;
cin >> H;
// ll res=0;
pr(atack_cnt(H));
return 0;
}
| replace | 25 | 26 | 25 | 26 | TLE | |
p02786 | C++ | Runtime Error | #include <algorithm>
#include <functional>
#include <iostream>
using namespace std;
long long func(long long H) {
if (H == 1)
return 1;
else {
return func(2 / H) + 1;
}
}
int main(void) {
long long H;
cin >> H;
cout << func(H) << endl;
return 0;
} | #include <algorithm>
#include <functional>
#include <iostream>
using namespace std;
long long func(long long H) {
if (H == 1)
return 1;
else {
return 2 * func(H / 2) + 1;
}
}
int main(void) {
long long H;
cin >> H;
cout << func(H) << endl;
return 0;
} | replace | 9 | 10 | 9 | 10 | 0 | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define si set<int>
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector<pii>
#define vpp vector<pair<int, pii>>
#define mii map<int, int>
#define mpi map<pii, int>
#define msi map<string, int>
#define loop(i, s, e) for (int i = s; i < e; i++)
#define rloop(i, e, s) for (int i = e; i >= s; i--)
#define mset(a, f) memset(a, f, sizeof(a))
#define spi set<pii>
#define endl "\n"
#define M 1000000007
#define sz(x) ((int)x.size())
#define all(p) p.begin(), p.end()
#define que_max priority_queue<int>
#define que_min priority_queue<int, vi, greater<int>>
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define print(a) \
for (auto x : a) \
cout << x << " "; \
cout << endl
#define Print(a, x, y) \
for (int i = x; i < y; i++) \
cout << a[i] << " "; \
cout << endl
inline int power(int a, int b) {
int x = 1;
while (b) {
if (b & 1)
x *= a;
a *= a;
b >>= 1;
}
return x;
}
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cout.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
const int N = 200005;
int arr[N];
int help(int x) {
int ans;
if (x == 1)
return 1;
else {
ans = help(x / 2);
}
return 2 * ans + 1;
}
void solve() {
int n;
cin >> n;
if (n % 2 != 0)
n--;
int ans = help(n);
cout << ans;
return;
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
clock_t z = clock();
int t = 1;
// cin >> t;
while (t--) {
solve();
}
cerr << "Total Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define si set<int>
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector<pii>
#define vpp vector<pair<int, pii>>
#define mii map<int, int>
#define mpi map<pii, int>
#define msi map<string, int>
#define loop(i, s, e) for (int i = s; i < e; i++)
#define rloop(i, e, s) for (int i = e; i >= s; i--)
#define mset(a, f) memset(a, f, sizeof(a))
#define spi set<pii>
#define endl "\n"
#define M 1000000007
#define sz(x) ((int)x.size())
#define all(p) p.begin(), p.end()
#define que_max priority_queue<int>
#define que_min priority_queue<int, vi, greater<int>>
#define bug(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define print(a) \
for (auto x : a) \
cout << x << " "; \
cout << endl
#define Print(a, x, y) \
for (int i = x; i < y; i++) \
cout << a[i] << " "; \
cout << endl
inline int power(int a, int b) {
int x = 1;
while (b) {
if (b & 1)
x *= a;
a *= a;
b >>= 1;
}
return x;
}
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
const char *comma = strchr(names + 1, ',');
cout.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
const int N = 200005;
int arr[N];
int help(int x) {
int ans;
if (x == 1)
return 1;
else {
ans = help(x / 2);
}
return 2 * ans + 1;
}
void solve() {
int n;
cin >> n;
if (n == 1) {
cout << 1;
return;
}
if (n % 2 != 0)
n--;
int ans = help(n);
cout << ans;
return;
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
clock_t z = clock();
int t = 1;
// cin >> t;
while (t--) {
solve();
}
cerr << "Total Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
return 0;
}
| insert | 74 | 74 | 74 | 78 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include "math.h"
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <typeinfo>
#include <vector>
#define pai 3.14159265358979323846264338327950288
using namespace std;
// Caracal vs Monster
int main() {
long long int h, cnt = 0, sum = 0;
cin >> h;
while (true) {
h /= 2;
sum += pow(2, cnt);
cnt++;
if (h == 1) {
sum += pow(2, cnt);
break;
}
}
cout << sum;
return 0;
}
| #include "math.h"
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <typeinfo>
#include <vector>
#define pai 3.14159265358979323846264338327950288
using namespace std;
// Caracal vs Monster
int main() {
long long int h, cnt = 0, sum = 0;
cin >> h;
while (true) {
if (h == 1) {
sum = 1;
break;
}
h /= 2;
sum += pow(2, cnt);
cnt++;
if (h == 1) {
sum += pow(2, cnt);
break;
}
}
cout << sum;
return 0;
} | insert | 20 | 20 | 20 | 24 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORN(i, b, a) for (int i = (b); _a = (a); i >= _a; i--)
#define REP(i, n) for (int i = 0, _n = n; i < n; i++)
#define ll long long
#define pii pair<int, int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define size(s) s.size()
using namespace std;
inline void read(int &x) {
short negative = 1;
x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
negative = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
x *= negative;
}
ll dg(ll n) {
if (n == 1)
return 1;
else
return dg(n / 2) + dg(n / 2) + 1;
}
int main() {
ll n;
cin >> n;
cout << dg(n) << endl;
return 0;
}
| #include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORN(i, b, a) for (int i = (b); _a = (a); i >= _a; i--)
#define REP(i, n) for (int i = 0, _n = n; i < n; i++)
#define ll long long
#define pii pair<int, int>
#define re return
#define vi vector<int>
#define pb push_back
#define si set<int>
#define in insert
#define fl float
#define db double
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define size(s) s.size()
using namespace std;
inline void read(int &x) {
short negative = 1;
x = 0;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
negative = -1;
c = getchar();
}
while (c >= '0' && c <= '9')
x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
x *= negative;
}
ll dg(ll n) {
if (n == 1)
return 1;
else
return dg(n / 2) * 2 + 1;
}
int main() {
ll n;
cin >> n;
cout << dg(n) << endl;
return 0;
}
| replace | 37 | 38 | 37 | 38 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX / 10
#define rep(i, n) for (int i = 0; i < n; i++)
#define krep(i, k, n, m) for (int i = k; i < n; i += m)
#define erep(i, k, n) for (int i = k; i < n; i++)
#define mod 1000000007
// 最大公約数
int gcd(int s, int b) {
if (b == 0)
return s;
return gcd(b, s % b);
}
signed main() {
int n;
cin >> n;
int w = 1, ans = 0;
while (1) {
ans += w;
w = w * 2;
n = n / 2;
if (n == 1) {
break;
}
}
cout << ans + w << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX / 10
#define rep(i, n) for (int i = 0; i < n; i++)
#define krep(i, k, n, m) for (int i = k; i < n; i += m)
#define erep(i, k, n) for (int i = k; i < n; i++)
#define mod 1000000007
// 最大公約数
int gcd(int s, int b) {
if (b == 0)
return s;
return gcd(b, s % b);
}
signed main() {
int n;
cin >> n;
int w = 1, ans = 0;
if (n == 1) {
cout << 1 << endl;
return 0;
}
while (1) {
ans += w;
w = w * 2;
n = n / 2;
if (n == 1) {
break;
}
}
cout << ans + w << endl;
}
| insert | 18 | 18 | 18 | 22 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
long long solve(long long x) { return 2 * solve(x / 2) + 1; }
int main() {
long long h;
cin >> h;
cout << solve(h) << endl;
} | #include <bits/stdc++.h>
using namespace std;
long long solve(long long x) {
if (x)
return 2 * solve(x / 2) + 1;
else
return 0;
}
int main() {
long long h;
cin >> h;
cout << solve(h) << endl;
}
| replace | 2 | 3 | 2 | 8 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a, b) for (int a = 0; a < b; a++)
#define Sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())
#define fi first
#define se second
#define co(a) cout << a << endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a, b, c) V<V<int>> a(b, V<int>(c))
#define V2a(a, b, c, d) V<V<int>> a(b, V<int>(c, d))
#define incin(a) \
int a; \
cin >> a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(), a.end()), a.end())
// #define min min<int>
// #define max max<int>
template <class T> void cou(vector<vector<T>> a) {
int b = a.size();
int c = a[0].size();
fo(i, b) {
fo(j, c) {
cout << a[i][j];
if (j == c - 1)
cout << endl;
else
cout << ' ';
}
}
}
/*template<>
void cou(vector<vector<char>> a){
int b=a.size();
int c=a[0].size();
fo(i,b){
fo(j,c){
cout<<a[i][j];
if(j==c-1)
cout<<endl;
else
cout<<' ';
}
}
}*/
int wari(int a, int b) {
if (a % b == 0)
return a / b;
else
return a / b + 1;
}
int keta(int a) {
double b = a;
b = log10(b);
int c = b;
return c + 1;
}
int souwa(int a) { return a * (a + 1) / 2; }
/*int lcm(int a,int b){
int d=a,e=b,f;
if(a<b)
swap(a,b);
int c,m=1;
while(m){
c=a%b;
if(c==0){
f=b;
m--;
}
else{
a=b;
b=c;
}
}
return d*e/f;
}
int gcm(int a,int b){
int d=a,e=b,f;
if(a<b)
swap(a,b);
int c,m=1;
while(m){
c=a%b;
if(c==0){
f=b;
m--;
}
else{
a=b;
b=c;
}
}
return f;
}*/
bool prime(int a) {
if (a < 2)
return false;
else if (a == 2)
return true;
else if (a % 2 == 0)
return false;
double b = sqrt(a);
for (int i = 3; i <= b; i += 2) {
if (a % i == 0) {
return false;
}
}
return true;
}
struct Union {
vector<int> par;
Union(int a) { par = vector<int>(a, -1); }
int find(int a) {
if (par[a] < 0)
return a;
else
return par[a] = find(par[a]);
}
bool same(int a, int b) { return find(a) == find(b); }
int Size(int a) { return -par[find(a)]; }
void unite(int a, int b) {
a = find(a);
b = find(b);
if (a == b)
return;
if (Size(b) > Size(a))
swap<int>(a, b);
par[a] += par[b];
par[b] = a;
}
};
int ketas(int a) {
string b = to_string(a);
int c = 0;
fo(i, keta(a)) { c += b[i] - '0'; }
return c;
}
int gcm(int a, int b) {
if (b == 0)
return a;
return gcm(b, a % b);
}
int lcm(int a, int b) { return a / gcm(a, b) * b; }
/*struct aa{
vector<int> gt;
aa(int n){
gt= vector<int>(n, 1);
}
void c(V<int> d,int b){
if(d[b]==0){
gt[d[b]-1]++;
gt[gt.sz-1]++;
}
else{
gt[d[b]-1]++;
c(d,d[d[b]]-1);
}
}
void cok(int a){
cout<<gt[a-1]<<endl;
fo(i,a-1)
cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){
}*/
signed main() {
int a;
cin >> a;
int b = 0;
int ans = 0;
while (a >= 0) {
a /= 2;
b++;
}
for (int i = 1; i <= b; i++) {
ans += ans * 2;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a, b) for (int a = 0; a < b; a++)
#define Sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())
#define fi first
#define se second
#define co(a) cout << a << endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a, b, c) V<V<int>> a(b, V<int>(c))
#define V2a(a, b, c, d) V<V<int>> a(b, V<int>(c, d))
#define incin(a) \
int a; \
cin >> a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(), a.end()), a.end())
// #define min min<int>
// #define max max<int>
template <class T> void cou(vector<vector<T>> a) {
int b = a.size();
int c = a[0].size();
fo(i, b) {
fo(j, c) {
cout << a[i][j];
if (j == c - 1)
cout << endl;
else
cout << ' ';
}
}
}
/*template<>
void cou(vector<vector<char>> a){
int b=a.size();
int c=a[0].size();
fo(i,b){
fo(j,c){
cout<<a[i][j];
if(j==c-1)
cout<<endl;
else
cout<<' ';
}
}
}*/
int wari(int a, int b) {
if (a % b == 0)
return a / b;
else
return a / b + 1;
}
int keta(int a) {
double b = a;
b = log10(b);
int c = b;
return c + 1;
}
int souwa(int a) { return a * (a + 1) / 2; }
/*int lcm(int a,int b){
int d=a,e=b,f;
if(a<b)
swap(a,b);
int c,m=1;
while(m){
c=a%b;
if(c==0){
f=b;
m--;
}
else{
a=b;
b=c;
}
}
return d*e/f;
}
int gcm(int a,int b){
int d=a,e=b,f;
if(a<b)
swap(a,b);
int c,m=1;
while(m){
c=a%b;
if(c==0){
f=b;
m--;
}
else{
a=b;
b=c;
}
}
return f;
}*/
bool prime(int a) {
if (a < 2)
return false;
else if (a == 2)
return true;
else if (a % 2 == 0)
return false;
double b = sqrt(a);
for (int i = 3; i <= b; i += 2) {
if (a % i == 0) {
return false;
}
}
return true;
}
struct Union {
vector<int> par;
Union(int a) { par = vector<int>(a, -1); }
int find(int a) {
if (par[a] < 0)
return a;
else
return par[a] = find(par[a]);
}
bool same(int a, int b) { return find(a) == find(b); }
int Size(int a) { return -par[find(a)]; }
void unite(int a, int b) {
a = find(a);
b = find(b);
if (a == b)
return;
if (Size(b) > Size(a))
swap<int>(a, b);
par[a] += par[b];
par[b] = a;
}
};
int ketas(int a) {
string b = to_string(a);
int c = 0;
fo(i, keta(a)) { c += b[i] - '0'; }
return c;
}
int gcm(int a, int b) {
if (b == 0)
return a;
return gcm(b, a % b);
}
int lcm(int a, int b) { return a / gcm(a, b) * b; }
/*struct aa{
vector<int> gt;
aa(int n){
gt= vector<int>(n, 1);
}
void c(V<int> d,int b){
if(d[b]==0){
gt[d[b]-1]++;
gt[gt.sz-1]++;
}
else{
gt[d[b]-1]++;
c(d,d[d[b]]-1);
}
}
void cok(int a){
cout<<gt[a-1]<<endl;
fo(i,a-1)
cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){
}*/
signed main() {
int h;
cin >> h;
if (h == 1)
cout << 1 << endl;
else if (h <= 3)
cout << 3 << endl;
else if (h <= 7)
cout << 7 << endl;
else if (h <= 15)
cout << 15 << endl;
else if (h <= 31)
cout << 31 << endl;
else if (h <= 63)
cout << 63 << endl;
else if (h <= 127)
cout << 127 << endl;
else if (h <= 255)
cout << 255 << endl;
else if (h <= 511)
cout << 511 << endl;
else if (h <= 1023)
cout << 1023 << endl;
else if (h <= 2047)
cout << 2047 << endl;
else if (h <= 4095)
cout << 4095 << endl;
else if (h <= 8191)
cout << 8191 << endl;
else if (h <= 16383)
cout << 16383 << endl;
else if (h <= 32767)
cout << 32767 << endl;
else if (h <= 65535)
cout << 65535 << endl;
else if (h <= 131071)
cout << 131071 << endl;
else if (h <= 262143)
cout << 262143 << endl;
else if (h <= 524287)
cout << 524287 << endl;
else if (h <= 1048575)
cout << 1048575 << endl;
else if (h <= 2097151)
cout << 2097151 << endl;
else if (h <= 4194303)
cout << 4194303 << endl;
else if (h <= 8388607)
cout << 8388607 << endl;
else if (h <= 10777215)
cout << 10777215 << endl;
else if (h <= 33554431)
cout << 33554431 << endl;
else if (h <= 67108863)
cout << 67108863 << endl;
else if (h <= 134217727)
cout << 134217727 << endl;
else if (h <= 268435455)
cout << 268435455 << endl;
else if (h <= 536870911)
cout << 536870911 << endl;
else if (h <= 1073741823)
cout << 1073741823 << endl;
else if (h <= 2147483647)
cout << 2147483647 << endl;
else if (h <= 4292967295)
cout << 4292967295 << endl;
else if (h <= 8589934591)
cout << 8589934591 << endl;
else if (h <= 17179869183)
cout << 17179869183 << endl;
else if (h <= 34359738367)
cout << 34359738367 << endl;
else if (h <= 68719476735)
cout << 6871947735 << endl;
else if (h <= 137438953471)
cout << 137438953741 << endl;
else if (h <= 274877906943)
cout << 274877906943 << endl;
else if (h <= 549755813887)
cout << 549755813887 << endl;
else
cout << 1099511627775 << endl;
}
| replace | 176 | 189 | 176 | 259 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
long long dfs(long long a) {
if (a == 1)
return 2;
return (dfs(a / 2) + 1) * 2;
}
int main() {
long long h;
cin >> h;
cout << dfs(h / 2) + 1;
} | #include <bits/stdc++.h>
using namespace std;
long long dfs(long long a) {
if (a == 1)
return 2;
return (dfs(a / 2) + 1) * 2;
}
int main() {
long long h;
cin >> h;
if (h == 1)
cout << 1;
else
cout << dfs(h / 2) + 1;
} | replace | 12 | 13 | 12 | 16 | TLE | |
p02786 | C++ | Time Limit Exceeded | /*coderanant*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define f1(i, a, b) for (int i = a; i < b; i++)
#define f2(i, a, b) for (int i = a; i >= b; i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair
const int mod = 1000000007;
ll temp;
int solve(int h) {
if (h == 1)
return 1;
return solve(h / 2) + solve(h / 2) + 1;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("/home/akmittal/Desktop/Competitive
// Programming/in.txt","r",stdin); freopen("/home/akmittal/Desktop/Competitive
// Programming/out.txt","w",stdout); #endif
int h;
cin >> h;
cout << solve(h);
return 0;
} | /*coderanant*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define f1(i, a, b) for (int i = a; i < b; i++)
#define f2(i, a, b) for (int i = a; i >= b; i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair
const int mod = 1000000007;
ll temp;
int solve(int h) {
if (h == 1)
return 1;
return 2 * solve(h / 2) + 1;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("/home/akmittal/Desktop/Competitive
// Programming/in.txt","r",stdin); freopen("/home/akmittal/Desktop/Competitive
// Programming/out.txt","w",stdout); #endif
int h;
cin >> h;
cout << solve(h);
return 0;
} | replace | 22 | 23 | 22 | 23 | TLE | |
p02786 | C++ | Runtime Error | #include <bits/stdc++.h>
#define INF 2147483647
#define int long long
#define _MATH_DEFINES_DEFINED
#pragma GCC optimize("O2")
using namespace std;
int tot, cs;
inline int read(void) {
int f = 1, n = 0;
char c = getchar();
while (!isdigit(c)) {
if (c == '-')
f = -1;
c = getchar();
}
while (isdigit(c)) {
n = n * 10 + (c - '0');
c = getchar();
}
return f * n;
}
void step(int h) {
if (h == 1)
tot += cs;
else
step(h >> 1), tot += cs;
cs *= 2;
return;
}
signed main(void) {
int h = read();
tot++, cs = 2;
step(h >> 1);
cout << tot << endl;
return 0;
} | #include <bits/stdc++.h>
#define INF 2147483647
#define int long long
#define _MATH_DEFINES_DEFINED
#pragma GCC optimize("O2")
using namespace std;
int tot, cs;
inline int read(void) {
int f = 1, n = 0;
char c = getchar();
while (!isdigit(c)) {
if (c == '-')
f = -1;
c = getchar();
}
while (isdigit(c)) {
n = n * 10 + (c - '0');
c = getchar();
}
return f * n;
}
void step(int h) {
if (h == 1)
tot += cs;
else
step(h >> 1), tot += cs;
cs *= 2;
return;
}
signed main(void) {
int h = read();
if (h == 1) {
cout << 1 << endl;
return 0;
}
tot++, cs = 2;
step(h >> 1);
cout << tot << endl;
return 0;
} | insert | 31 | 31 | 31 | 35 | 0 | |
p02786 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll func(ll n) {
if (n == 1)
return 1;
return 2 * func(n / 2) + 1;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll h;
cin >> h;
ll ans = func(h);
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll func(ll n) {
if (n == 1)
return 1;
return 2 * func(n / 2) + 1;
}
int main() {
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll h;
cin >> h;
ll ans = func(h);
cout << ans;
return 0;
} | replace | 14 | 15 | 14 | 15 | 0 | |
p02786 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rg register
#define us unsigned
#define ll long long
#define ui <int>
#define pi <int, int>
#define tmpl template <typename typ>
#define oprt operator
#define sp putchar(32)
#define el putchar(10)
#define flin(x) freopen(x, "r", stdin)
#define flout(x) freopen(x, "w", stdout)
#define flio(x) flin(x ".in"), flout(x ".out")
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define itrt iterator
using namespace std;
tmpl inline bool up(typ &x, const typ &y) { return x < y ? x = y, 1 : 0; }
tmpl inline bool dn(typ &x, const typ &y) { return y < x ? x = y, 1 : 0; }
tmpl inline bool inr(const typ &x, const typ &l, const typ &r) {
return !(x < l) && !(r < x);
}
namespace orh {
inline void useios() {
ios_base::sync_with_stdio(false);
cin.tie(0);
}
inline char rc() {
rg char ch;
while (!isgraph(ch = getchar()))
;
return ch;
}
tmpl typ ri() {
rg typ x = 0;
rg bool neg = false;
rg char ch;
while (!inr(ch = getchar(), '0', '9'))
neg |= ch == '-';
do
x = (x << 1) + (x << 3) + (ch ^ 48);
while (inr(ch = getchar(), '0', '9'));
return neg ? -x : x;
}
tmpl typ ru() {
rg typ x = 0;
rg char ch;
while (!inr(ch = getchar(), '0', '9'))
;
do
x = (x << 1) + (x << 3) + (ch ^ 48);
while (inr(ch = getchar(), '0', '9'));
return x;
}
tmpl void wi(rg typ x) {
if (x < 0) {
putchar('-');
x = -x;
}
static int sta[42];
rg int top = 0;
rg typ t;
do
t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t;
while (x);
while (top)
putchar(sta[--top] ^ 48);
}
tmpl void wu(rg typ x) {
static int sta[42];
rg int top = 0;
rg typ t;
do
t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t;
while (x);
while (top)
putchar(sta[--top] ^ 48);
}
} // namespace orh
ll n;
ll dfs(int x) {
if (x == 1)
return 1;
ll t = dfs(x / 2ll);
return t + t + 1;
}
signed main() {
orh::useios();
cin >> n;
cout << dfs(n) << endl;
return 0;
} | #include <bits/stdc++.h>
#define rg register
#define us unsigned
#define ll long long
#define ui <int>
#define pi <int, int>
#define tmpl template <typename typ>
#define oprt operator
#define sp putchar(32)
#define el putchar(10)
#define flin(x) freopen(x, "r", stdin)
#define flout(x) freopen(x, "w", stdout)
#define flio(x) flin(x ".in"), flout(x ".out")
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define itrt iterator
using namespace std;
tmpl inline bool up(typ &x, const typ &y) { return x < y ? x = y, 1 : 0; }
tmpl inline bool dn(typ &x, const typ &y) { return y < x ? x = y, 1 : 0; }
tmpl inline bool inr(const typ &x, const typ &l, const typ &r) {
return !(x < l) && !(r < x);
}
namespace orh {
inline void useios() {
ios_base::sync_with_stdio(false);
cin.tie(0);
}
inline char rc() {
rg char ch;
while (!isgraph(ch = getchar()))
;
return ch;
}
tmpl typ ri() {
rg typ x = 0;
rg bool neg = false;
rg char ch;
while (!inr(ch = getchar(), '0', '9'))
neg |= ch == '-';
do
x = (x << 1) + (x << 3) + (ch ^ 48);
while (inr(ch = getchar(), '0', '9'));
return neg ? -x : x;
}
tmpl typ ru() {
rg typ x = 0;
rg char ch;
while (!inr(ch = getchar(), '0', '9'))
;
do
x = (x << 1) + (x << 3) + (ch ^ 48);
while (inr(ch = getchar(), '0', '9'));
return x;
}
tmpl void wi(rg typ x) {
if (x < 0) {
putchar('-');
x = -x;
}
static int sta[42];
rg int top = 0;
rg typ t;
do
t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t;
while (x);
while (top)
putchar(sta[--top] ^ 48);
}
tmpl void wu(rg typ x) {
static int sta[42];
rg int top = 0;
rg typ t;
do
t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t;
while (x);
while (top)
putchar(sta[--top] ^ 48);
}
} // namespace orh
ll n;
ll dfs(ll x) {
if (x == 1)
return 1;
ll t = dfs(x / 2ll);
return t + t + 1;
}
signed main() {
orh::useios();
cin >> n;
cout << dfs(n) << endl;
return 0;
} | replace | 85 | 86 | 85 | 86 | 0 | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int64_t times2(int64_t n) {
int64_t output = 1;
for (int64_t i = 0; i < n; ++i) {
output *= 2;
}
return output;
}
int main() {
// input
int64_t H;
cin >> H;
// calculation
int64_t count = 1;
while (1) {
H /= 2;
count++;
if (H == 1) {
break;
}
}
int64_t output = times2(count) - 1;
// output
cout << output << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int64_t times2(int64_t n) {
int64_t output = 1;
for (int64_t i = 0; i < n; ++i) {
output *= 2;
}
return output;
}
int main() {
// input
int64_t H;
cin >> H;
// calculation
if (H == 1) {
cout << 1 << endl;
return 0;
}
int64_t count = 1;
while (1) {
H /= 2;
count++;
if (H == 1) {
break;
}
}
int64_t output = times2(count) - 1;
// output
cout << output << endl;
return 0;
}
| insert | 17 | 17 | 17 | 22 | TLE | |
p02786 | C++ | Runtime Error | #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()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
// const double PI = acos(-1);
// const double EPS = 1e-15;
// long long INF=(long long)1E17;
#define i_7 (long long)(1e9 + 7)
// #define i_7 998'244'353
long mod(long a) {
long long c = a % i_7;
if (c >= 0)
return c;
return c + i_7;
}
long long po(long a, long b) {
if (b == 0) {
return 1;
}
long long z = po(a, b / 2);
z = mod(z * z);
if (b % 2 != 0) {
z = mod(a * z);
}
return z;
}
bool prime_(int n) {
if (n == 1) {
return false;
} else if (n == 2) {
return true;
} else {
for (int i = 2; i <= std::sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
}
long long gcd_(long long a, long long b) {
if (a < b) {
std::swap(a, b);
}
if (a % b == 0) {
return b;
} else {
return gcd_(b, a % b);
}
}
long long lcm_(long long x, long long y) { return (x / gcd_(x, y)) * y; }
// using namespace std;
// using namespace boost::multiprecision;
// using namespace __gnu_pbds;
std::map<long long, long long> dp;
long long dfs(long long x) {
long long res;
res = 1 + 2 * dfs(x / 2);
return dp[x] = res;
}
int main() {
using namespace std;
long long h;
cin >> h;
dp[1] = 1;
long long ans = dfs(h);
cout << ans << endl;
return 0;
}
| #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()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
// const double PI = acos(-1);
// const double EPS = 1e-15;
// long long INF=(long long)1E17;
#define i_7 (long long)(1e9 + 7)
// #define i_7 998'244'353
long mod(long a) {
long long c = a % i_7;
if (c >= 0)
return c;
return c + i_7;
}
long long po(long a, long b) {
if (b == 0) {
return 1;
}
long long z = po(a, b / 2);
z = mod(z * z);
if (b % 2 != 0) {
z = mod(a * z);
}
return z;
}
bool prime_(int n) {
if (n == 1) {
return false;
} else if (n == 2) {
return true;
} else {
for (int i = 2; i <= std::sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
}
long long gcd_(long long a, long long b) {
if (a < b) {
std::swap(a, b);
}
if (a % b == 0) {
return b;
} else {
return gcd_(b, a % b);
}
}
long long lcm_(long long x, long long y) { return (x / gcd_(x, y)) * y; }
// using namespace std;
// using namespace boost::multiprecision;
// using namespace __gnu_pbds;
std::map<long long, long long> dp;
long long dfs(long long x) {
long long res;
if (dp[x] > 0) {
return dp[x];
}
res = 1 + 2 * dfs(x / 2);
return dp[x] = res;
}
int main() {
using namespace std;
long long h;
cin >> h;
dp[1] = 1;
long long ans = dfs(h);
cout << ans << endl;
return 0;
} | insert | 70 | 70 | 70 | 73 | -11 | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long long h, a, b, c, i, j, k, n, m, x, y, ans = 0;
string str;
cin >> h;
c = 1;
while (1) {
ans += c;
c = c * 2;
h = h / 2;
if (h == 1) {
ans += c;
break;
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long h, a, b, c, i, j, k, n, m, x, y, ans = 0;
string str;
cin >> h;
if (h == 1) {
cout << 1 << endl;
return 0;
}
c = 1;
while (1) {
ans += c;
c = c * 2;
h = h / 2;
if (h == 1) {
ans += c;
break;
}
}
cout << ans << endl;
}
| insert | 9 | 9 | 9 | 13 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5;
ll arr[N + 5];
int main() {
ll total = 0;
ll n;
cin >> n;
ll cur = 1;
while (n) {
if (n == 1)
total += cur;
else {
total += cur;
n /= 2;
cur *= 2;
}
}
cout << total << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5;
ll arr[N + 5];
int main() {
ll total = 0;
ll n;
cin >> n;
ll cur = 1;
while (n) {
total += cur;
n /= 2;
cur *= 2;
}
cout << total << endl;
} | replace | 13 | 20 | 13 | 16 | TLE | |
p02786 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(
chrono::high_resolution_clock::now().time_since_epoch())
.count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N = 400015;
#define M 1000000007
#define double long double
#define BINF 100000000000000
#define init(arr, val) memset(arr, val, sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;
map<int, int> lol;
#undef int
int main() {
#define int long long int
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("ip.txt", "r", stdin);
freopen("op1.txt", "w", stdout);
#endif
int n;
cin >> n;
int ans = 0;
while (n > 0) {
if (lol[n] == 0) {
ans++;
lol[n / 2] += 2;
} else {
ans += lol[n];
lol[n / 2] += 2 * lol[n];
}
n /= 2;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(std::chrono::duration_cast<std::chrono::nanoseconds>(
chrono::high_resolution_clock::now().time_since_epoch())
.count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N = 400015;
#define M 1000000007
#define double long double
#define BINF 100000000000000
#define init(arr, val) memset(arr, val, sizeof(arr))
#define MAXN 15000001
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;
map<int, int> lol;
#undef int
int main() {
#define int long long int
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int ans = 0;
while (n > 0) {
if (lol[n] == 0) {
ans++;
lol[n / 2] += 2;
} else {
ans += lol[n];
lol[n / 2] += 2 * lol[n];
}
n /= 2;
}
cout << ans << endl;
return 0;
}
| delete | 27 | 31 | 27 | 27 | 0 | |
p02786 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
long long H;
cin >> H;
int count = 0;
while (true) {
H = H / 2;
count++;
if (H == 1)
break;
}
// cout<<count<<endl;
long long sum = 0;
for (int i = 0; i <= count; i++) {
sum += pow(2, i);
}
cout << sum << endl;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
long long H;
cin >> H;
int count = 0;
if (H == 1) {
cout << 1 << endl;
return 0;
}
while (true) {
H = H / 2;
count++;
if (H == 1)
break;
}
// cout<<count<<endl;
long long sum = 0;
for (int i = 0; i <= count; i++) {
sum += pow(2, i);
}
cout << sum << endl;
} | insert | 10 | 10 | 10 | 14 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long H;
cin >> H;
long cnt = 0;
long i = 0;
while (H >= 1) {
cnt += pow(2, i);
i++;
}
cout << cnt;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long H;
cin >> H;
long cnt = 0;
long i = 0;
while (H >= 1) {
cnt += pow(2, i);
i++;
H = H / 2;
}
cout << cnt;
} | insert | 11 | 11 | 11 | 12 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
long long dfs(long long n) {
if (n == 1)
return 1;
else
return dfs(n / 2) + dfs(n / 2) + 1;
}
int main() {
long long n;
cin >> n;
cout << dfs(n);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
long long dfs(long long n) {
if (n == 1)
return 1;
else
return dfs(n / 2) * 2 + 1;
}
int main() {
long long n;
cin >> n;
cout << dfs(n);
return 0;
} | replace | 6 | 7 | 6 | 7 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int H;
cin >> H;
if (H == 1) {
puts("1");
return 0;
}
int b = 1;
while ((1 << b) <= H)
b++;
cout << (1 << b) - 1 << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int H;
cin >> H;
if (H == 1) {
puts("1");
return 0;
}
int b = (int)log2(H) + 1;
cout << (1LL << b) - 1 << endl;
}
| replace | 12 | 17 | 12 | 14 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
long solve(long n) {
if (n == 1)
return 1;
else
return 2 * solve(n / 2) + 1;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input", "r", stdin);
freopen("output", "w", stdout);
#endif
long n;
cin >> n;
long ans = solve(n);
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
long solve(long n) {
if (n == 1)
return 1;
else
return 2 * solve(n / 2) + 1;
}
int main() {
long n;
cin >> n;
long ans = solve(n);
cout << ans;
return 0;
} | delete | 11 | 15 | 11 | 11 | TLE | |
p02786 | C++ | Time Limit Exceeded | /*
本宝的程序外人别想看!!
name: [夏宝宝]
run time:[] ms
compilation time: [] ms
output memory: [] MiB
where: []
state: []
*/
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int s1, s2 = 1;
cin >> s1;
long long int sum;
while (s2 > 0) {
sum += s2;
s2 *= 2;
s1 = floor(s1 / 2);
}
cout << sum << endl;
return 0;
} | /*
本宝的程序外人别想看!!
name: [夏宝宝]
run time:[] ms
compilation time: [] ms
output memory: [] MiB
where: []
state: []
*/
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int s1, s2 = 1;
cin >> s1;
long long int sum;
while (s1 > 0) {
sum += s2;
s2 *= 2;
s1 = floor(s1 / 2);
}
cout << sum << endl;
return 0;
} | replace | 20 | 21 | 20 | 21 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll h;
cin >> h;
ll r = 1;
while (h) {
h >> 1;
r << 1;
}
cout << r - 1 << endl;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll h;
cin >> h;
ll r = 1;
while (h) {
h >>= 1;
r <<= 1;
}
cout << r - 1 << endl;
} | replace | 9 | 11 | 9 | 11 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main(void) {
long long int h, c = 1, x = 0, v = 0, i, p = 0;
cin >> h;
while (1) {
h = h / 2;
c = c * 2;
p += c / 2;
if (h == 1) {
break;
}
}
p = c + p;
cout << p << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main(void) {
long long int h, c = 1, x = 0, v = 0, i, p = 0;
cin >> h;
if (h == 1) {
cout << "1" << endl;
return 0;
}
while (1) {
h = h / 2;
c = c * 2;
p += c / 2;
if (h == 1) {
break;
}
}
p = c + p;
cout << p << endl;
return 0;
}
| insert | 5 | 5 | 5 | 9 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a, b) for (int a = 0; a < b; a++)
#define Sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())
#define fi first
#define se second
#define co(a) cout << a << endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a, b, c) V<V<int>> a(b, V<int>(c))
#define V2a(a, b, c, d) V<V<int>> a(b, V<int>(c, d))
#define incin(a) \
int a; \
cin >> a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(), a.end()), a.end())
// #define min min<int>
// #define max max<int>
template <class T> void cou(vector<vector<T>> a) {
int b = a.size();
int c = a[0].size();
fo(i, b) {
fo(j, c) {
cout << a[i][j];
if (j == c - 1)
cout << endl;
else
cout << ' ';
}
}
}
/*template<>
void cou(vector<vector<char>> a){
int b=a.size();
int c=a[0].size();
fo(i,b){
fo(j,c){
cout<<a[i][j];
if(j==c-1)
cout<<endl;
else
cout<<' ';
}
}
}*/
int wari(int a, int b) {
if (a % b == 0)
return a / b;
else
return a / b + 1;
}
int keta(int a) {
double b = a;
b = log10(b);
int c = b;
return c + 1;
}
int souwa(int a) { return a * (a + 1) / 2; }
/*int lcm(int a,int b){
int d=a,e=b,f;
if(a<b)
swap(a,b);
int c,m=1;
while(m){
c=a%b;
if(c==0){
f=b;
m--;
}
else{
a=b;
b=c;
}
}
return d*e/f;
}
int gcm(int a,int b){
int d=a,e=b,f;
if(a<b)
swap(a,b);
int c,m=1;
while(m){
c=a%b;
if(c==0){
f=b;
m--;
}
else{
a=b;
b=c;
}
}
return f;
}*/
bool prime(int a) {
if (a < 2)
return false;
else if (a == 2)
return true;
else if (a % 2 == 0)
return false;
double b = sqrt(a);
for (int i = 3; i <= b; i += 2) {
if (a % i == 0) {
return false;
}
}
return true;
}
struct Union {
vector<int> par;
Union(int a) { par = vector<int>(a, -1); }
int find(int a) {
if (par[a] < 0)
return a;
else
return par[a] = find(par[a]);
}
bool same(int a, int b) { return find(a) == find(b); }
int Size(int a) { return -par[find(a)]; }
void unite(int a, int b) {
a = find(a);
b = find(b);
if (a == b)
return;
if (Size(b) > Size(a))
swap<int>(a, b);
par[a] += par[b];
par[b] = a;
}
};
int ketas(int a) {
string b = to_string(a);
int c = 0;
fo(i, keta(a)) { c += b[i] - '0'; }
return c;
}
int gcm(int a, int b) {
if (b == 0)
return a;
return gcm(b, a % b);
}
int lcm(int a, int b) { return a / gcm(a, b) * b; }
/*struct aa{
vector<int> gt;
aa(int n){
gt= vector<int>(n, 1);
}
void c(V<int> d,int b){
if(d[b]==0){
gt[d[b]-1]++;
gt[gt.sz-1]++;
}
else{
gt[d[b]-1]++;
c(d,d[d[b]]-1);
}
}
void cok(int a){
cout<<gt[a-1]<<endl;
fo(i,a-1)
cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){
}*/
signed main() {
int a;
cin >> a;
int b = a;
int c = 0;
int d = 0;
while (b >= 0) {
b /= 2;
c++;
}
d = pow(2, c);
cout << d - 1 << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a, b) for (int a = 0; a < b; a++)
#define Sort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())
#define fi first
#define se second
#define co(a) cout << a << endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a, b, c) V<V<int>> a(b, V<int>(c))
#define V2a(a, b, c, d) V<V<int>> a(b, V<int>(c, d))
#define incin(a) \
int a; \
cin >> a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(), a.end()), a.end())
// #define min min<int>
// #define max max<int>
template <class T> void cou(vector<vector<T>> a) {
int b = a.size();
int c = a[0].size();
fo(i, b) {
fo(j, c) {
cout << a[i][j];
if (j == c - 1)
cout << endl;
else
cout << ' ';
}
}
}
/*template<>
void cou(vector<vector<char>> a){
int b=a.size();
int c=a[0].size();
fo(i,b){
fo(j,c){
cout<<a[i][j];
if(j==c-1)
cout<<endl;
else
cout<<' ';
}
}
}*/
int wari(int a, int b) {
if (a % b == 0)
return a / b;
else
return a / b + 1;
}
int keta(int a) {
double b = a;
b = log10(b);
int c = b;
return c + 1;
}
int souwa(int a) { return a * (a + 1) / 2; }
/*int lcm(int a,int b){
int d=a,e=b,f;
if(a<b)
swap(a,b);
int c,m=1;
while(m){
c=a%b;
if(c==0){
f=b;
m--;
}
else{
a=b;
b=c;
}
}
return d*e/f;
}
int gcm(int a,int b){
int d=a,e=b,f;
if(a<b)
swap(a,b);
int c,m=1;
while(m){
c=a%b;
if(c==0){
f=b;
m--;
}
else{
a=b;
b=c;
}
}
return f;
}*/
bool prime(int a) {
if (a < 2)
return false;
else if (a == 2)
return true;
else if (a % 2 == 0)
return false;
double b = sqrt(a);
for (int i = 3; i <= b; i += 2) {
if (a % i == 0) {
return false;
}
}
return true;
}
struct Union {
vector<int> par;
Union(int a) { par = vector<int>(a, -1); }
int find(int a) {
if (par[a] < 0)
return a;
else
return par[a] = find(par[a]);
}
bool same(int a, int b) { return find(a) == find(b); }
int Size(int a) { return -par[find(a)]; }
void unite(int a, int b) {
a = find(a);
b = find(b);
if (a == b)
return;
if (Size(b) > Size(a))
swap<int>(a, b);
par[a] += par[b];
par[b] = a;
}
};
int ketas(int a) {
string b = to_string(a);
int c = 0;
fo(i, keta(a)) { c += b[i] - '0'; }
return c;
}
int gcm(int a, int b) {
if (b == 0)
return a;
return gcm(b, a % b);
}
int lcm(int a, int b) { return a / gcm(a, b) * b; }
/*struct aa{
vector<int> gt;
aa(int n){
gt= vector<int>(n, 1);
}
void c(V<int> d,int b){
if(d[b]==0){
gt[d[b]-1]++;
gt[gt.sz-1]++;
}
else{
gt[d[b]-1]++;
c(d,d[d[b]]-1);
}
}
void cok(int a){
cout<<gt[a-1]<<endl;
fo(i,a-1)
cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){
}*/
signed main() {
int a;
cin >> a;
int b = a;
int c = 0;
int d = 0;
while (b > 0) {
b /= 2;
c++;
}
d = pow(2, c);
cout << d - 1 << endl;
}
| replace | 181 | 182 | 181 | 182 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long long h, a = 1, s = 0;
cin >> h;
while (h >= 1) {
s += a;
a *= 2;
}
cout << s;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long h, a = 1, s = 0;
cin >> h;
while (h >= 1) {
s += a;
a *= 2;
h /= 2;
}
cout << s;
}
| insert | 8 | 8 | 8 | 9 | TLE | |
p02786 | C++ | Time Limit Exceeded | #include <iostream>
#include <vector>
using namespace std;
#define ll long long
// 16:12 from
int main() {
// the biggest power of 2 that doesnot exceed n
ll h;
ll b = 1;
while (2 * b <= h)
b *= 2;
cout << 2 * b - 1;
}
// int h;
// cin>>h;
// vector<int> dp(h+1);
// dp[0]=0;
// dp[1]=1;
// for(int i=2;i<=h;i++){
// dp[i]=1+2*dp[i/2];
// }
// cout<<dp[h];
// return 0;
// #include <bit>
// This containe __builtin
// look at the video from 16:12 | #include <iostream>
#include <vector>
using namespace std;
#define ll long long
// 16:12 from
int main() {
// the biggest power of 2 that doesnot exceed n
ll h;
cin >> h;
ll b = 1;
while (2 * b <= h)
b *= 2;
cout << 2 * b - 1;
}
// int h;
// cin>>h;
// vector<int> dp(h+1);
// dp[0]=0;
// dp[1]=1;
// for(int i=2;i<=h;i++){
// dp[i]=1+2*dp[i/2];
// }
// cout<<dp[h];
// return 0;
// #include <bit>
// This containe __builtin
// look at the video from 16:12 | insert | 9 | 9 | 9 | 10 | TLE | |
p02787 | Python | Time Limit Exceeded | MAX_LIMIT = 1e30
H, N = list(map(int, input().split()))
A, B = [], []
for _ in range(N):
a, b = list(map(int, input().split()))
A.append(a) # HP
B.append(b) # power
# dp[i] means minimum power used to reduce HP i
dp = [MAX_LIMIT] * (H + max(A))
dp[0] = 0
for i in range(1, H + max(A)):
cands = []
for a, b in zip(A, B):
if i - a >= 0:
cands.append(b + dp[i - a])
if len(cands) == 0:
dp[i] = MAX_LIMIT # we cannot directly reach this point
else:
dp[i] = min(cands)
# print(dp)
print(min(dp[H:]))
| h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
dp = [0] * (h + max(a for a, b in ab))
for i in range(1, h + 1):
dp[i] = min(dp[i - a] + b for a, b in ab)
print(dp[h])
| replace | 0 | 24 | 0 | 6 | TLE | |
p02787 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long lol;
// マクロ
// forループ関係
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (lol i = 0; i < lol(n); i++)
#define REPD(i, n) for (lol i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (lol i = a; i <= lol(b); i++)
#define FORD(i, a, b) for (lol i = a; i >= lol(b); i--)
#define VL vector<lol>
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end() // sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) // sizeをsize_tからllに直しておく
// 定数
#define PI 3.1415926535897932385 // pi
#define INF 1000000000000 // 10^12:極めて大きい値,∞
#define MOD 1000000007 // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
// 最大値最小値
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
lol dp[1005][10005], n;
lol a[1005], b[10005];
lol f(lol idx, lol hp) {
if (hp <= 0)
return 0;
if (idx > n)
return INF;
lol sol = dp[idx][hp];
if (sol != -1)
return sol;
return sol = min(f(idx + 1, hp), f(idx, hp - a[idx]) + b[idx]);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
lol result{0};
lol h;
cin >> h >> n;
FOR(i, 1, n) { cin >> a[i] >> b[i]; }
memset(dp, -1, sizeof(dp));
result = f(1, h);
cout << result << '\n';
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long lol;
// マクロ
// forループ関係
// 引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (lol i = 0; i < lol(n); i++)
#define REPD(i, n) for (lol i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (lol i = a; i <= lol(b); i++)
#define FORD(i, a, b) for (lol i = a; i >= lol(b); i--)
#define VL vector<lol>
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end() // sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) // sizeをsize_tからllに直しておく
// 定数
#define PI 3.1415926535897932385 // pi
#define INF 1000000000000 // 10^12:極めて大きい値,∞
#define MOD 1000000007 // 10^9+7:合同式の法
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
// 最大値最小値
template <class T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool chmin(T &a, const T &b) {
if (b < a) {
a = b;
return 1;
}
return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
lol dp[1005][10005], n;
lol a[1005], b[10005];
lol f(lol idx, lol hp) {
if (hp <= 0)
return 0;
if (idx > n)
return INF;
lol &sol = dp[idx][hp];
if (sol != -1)
return sol;
return sol = min(f(idx + 1, hp), f(idx, hp - a[idx]) + b[idx]);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
lol result{0};
lol h;
cin >> h >> n;
FOR(i, 1, n) { cin >> a[i] >> b[i]; }
memset(dp, -1, sizeof(dp));
result = f(1, h);
cout << result << '\n';
return 0;
} | replace | 46 | 47 | 46 | 47 | TLE | |
p02787 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1001001001;
int main() {
int n, h;
cin >> h >> n;
vector<int> a(n), b(n);
rep(i, n) cin >> a[i] >> b[i];
// dp[i][j] i番目までの魔法、モンスターのHPjまでの最小魔法消費量
vector<vector<int>> dp(n + 1, vector<int>(h + 1));
rep(i, n + 1) rep(j, h + 2) dp[i][j] = INF;
rep(i, n) dp[i][0] = 0;
rep(i, n) {
rep(j, h + 1) {
if (j - a[i] >= 0) {
dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - a[i]] + b[i]);
} else
dp[i + 1][j] = min(dp[i][j], dp[i + 1][0] + b[i]);
// cout << dp[i+1][j] << " ";
}
// cout << endl;
}
cout << dp[n][h] << endl;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1001001001;
int main() {
int n, h;
cin >> h >> n;
vector<int> a(n), b(n);
rep(i, n) cin >> a[i] >> b[i];
// dp[i][j] i番目までの魔法、モンスターのHPjまでの最小魔法消費量
vector<vector<int>> dp(n + 1, vector<int>(h + 1));
rep(i, n + 1) rep(j, h + 1) dp[i][j] = INF;
rep(i, n) dp[i][0] = 0;
rep(i, n) {
rep(j, h + 1) {
if (j - a[i] >= 0) {
dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - a[i]] + b[i]);
} else
dp[i + 1][j] = min(dp[i][j], dp[i + 1][0] + b[i]);
// cout << dp[i+1][j] << " ";
}
// cout << endl;
}
cout << dp[n][h] << endl;
} | replace | 14 | 15 | 14 | 15 | -6 | malloc(): corrupted top size
|
p02787 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define MOD (long long)(1E9 + 7)
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int h, n, t = 0;
cin >> h >> n;
int dp[n + 1][h + 1];
vector<int> a(n);
vector<int> b(n);
rep(i, n) {
cin >> a[i] >> b[i];
for (int j = 0; j <= h; j++) {
t = (b[i] * ((j - 1) / a[i] + 1));
if (i == 0) {
dp[i][j] = t;
continue;
}
dp[i][j] = min(t, dp[i - 1][j]);
for (int k = 1; j >= a[i] * k; k++) {
dp[i][j] = min(dp[i][j], dp[i - 1][j - a[i] * k] + b[i] * k);
}
}
}
cout << dp[n - 1][h] << endl;
}
| #include <bits/stdc++.h>
#define MOD (long long)(1E9 + 7)
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
int h, n, t = 0;
cin >> h >> n;
int dp[n + 1][h + 1];
vector<int> a(n);
vector<int> b(n);
rep(i, n) {
cin >> a[i] >> b[i];
for (int j = 0; j <= h; j++) {
t = (b[i] * ((j - 1) / a[i] + 1));
if (i == 0) {
dp[i][j] = t;
continue;
}
dp[i][j] = min(t, dp[i - 1][j]);
if (j >= a[i]) {
dp[i][j] = min(dp[i][j], dp[i][j - a[i]] + b[i]);
}
}
}
cout << dp[n - 1][h] << endl;
}
| replace | 21 | 23 | 21 | 23 | TLE | |
p02787 | C++ | Runtime Error | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
template <class T> bool chmin(T &v, const T &v2) {
if (v > v2) {
v = v2;
return true;
} else
return false;
}
using namespace std;
auto main() -> int {
int H, N;
cin >> H >> N;
vector<int> dp(10001, 1e9);
dp[0] = 0;
while (N--) {
int damage, mp;
cin >> damage >> mp;
REP(i, H) chmin(dp[i + damage], dp[i] + mp);
}
REPR(i, dp.size() - 2) chmin(dp[i], dp[i + 1]);
cout << dp[H] << endl;
} | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
template <class T> bool chmin(T &v, const T &v2) {
if (v > v2) {
v = v2;
return true;
} else
return false;
}
using namespace std;
auto main() -> int {
int H, N;
cin >> H >> N;
vector<int> dp(100000, 1e9);
dp[0] = 0;
while (N--) {
int damage, mp;
cin >> damage >> mp;
REP(i, H) chmin(dp[i + damage], dp[i] + mp);
}
REPR(i, dp.size() - 2) chmin(dp[i], dp[i + 1]);
cout << dp[H] << endl;
} | replace | 20 | 21 | 20 | 21 | 0 | |
p02787 | C++ | Runtime Error | /* # */
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
// #pragma warning(disable:4996)
using namespace std;
/** Type Define **/
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<char> vch;
constexpr int inf = 0x3f3f3f3f;
constexpr long long INF = 9123456789123456789;
constexpr long long MOD = 1000000007LL;
/*************************************************/
int H, N;
vi dp;
void Min(int &x, int y) {
if (x > y)
x = y;
}
void sol() {
for (int i = 0; i < N; i++) {
int a, b; // a: damage, b: cost.
cin >> a >> b;
for (int i = 0; i < a; i++)
Min(dp[i], b);
for (int i = a; i <= H; i++)
Min(dp[i], dp[i - a] + b);
}
}
int main() {
ios_base::sync_with_stdio(false);
// cout << fixed << setprecision(10);
cin.tie(nullptr);
cin >> H >> N;
dp.assign(H + 1, inf);
dp[0] = 0;
sol();
cout << dp[H] << '\n';
return 0;
}
| /* # */
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
// #pragma warning(disable:4996)
using namespace std;
/** Type Define **/
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<char> vch;
constexpr int inf = 0x3f3f3f3f;
constexpr long long INF = 9123456789123456789;
constexpr long long MOD = 1000000007LL;
/*************************************************/
int H, N;
vi dp;
void Min(int &x, int y) {
if (x > y)
x = y;
}
void sol() {
for (int i = 0; i < N; i++) {
int a, b; // a: damage, b: cost.
cin >> a >> b;
for (int i = 0; i < a; i++)
Min(dp[i], b);
for (int i = a; i <= H; i++)
Min(dp[i], dp[i - a] + b);
}
}
int main() {
ios_base::sync_with_stdio(false);
// cout << fixed << setprecision(10);
cin.tie(nullptr);
cin >> H >> N;
dp.assign(10001, INT32_MAX);
dp[0] = 0;
sol();
cout << dp[H] << '\n';
return 0;
}
| replace | 58 | 59 | 58 | 59 | 0 | |
p02787 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 20;
const int INF = 0x3f3f3f3f;
int p[maxn], v[maxn];
int dp[10000 + 50];
int main() {
int n, m;
while (scanf("%d %d", &m, &n) != EOF) {
for (int i = 1; i <= n; i++) {
scanf("%d %d", &v[i], &p[i]);
}
memset(dp, INF, sizeof(dp));
dp[0] = 0;
for (int i = 1; i <= n; i++) {
for (int j = v[i]; j <= 20000; j++) {
dp[j] = min(dp[j], dp[j - v[i]] + p[i]);
}
}
int maxx = dp[m];
int ans = m;
for (int i = m; i <= 10000; i++) {
if (dp[i] <= maxx) {
maxx = dp[i];
ans = i;
}
}
printf("%d\n", maxx);
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 20;
const int INF = 0x3f3f3f3f;
int p[maxn], v[maxn];
int dp[20000 + 50];
int main() {
int n, m;
while (scanf("%d %d", &m, &n) != EOF) {
for (int i = 1; i <= n; i++) {
scanf("%d %d", &v[i], &p[i]);
}
memset(dp, INF, sizeof(dp));
dp[0] = 0;
for (int i = 1; i <= n; i++) {
for (int j = v[i]; j <= 20000; j++) {
dp[j] = min(dp[j], dp[j - v[i]] + p[i]);
}
}
int maxx = dp[m];
int ans = m;
for (int i = m; i <= 10000; i++) {
if (dp[i] <= maxx) {
maxx = dp[i];
ans = i;
}
}
printf("%d\n", maxx);
}
return 0;
}
| replace | 5 | 6 | 5 | 6 | -11 | |
p02787 | C++ | Runtime Error | #include <iostream>
#include <stdio.h>
// #include <bits/stdc++.h>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <float.h>
#include <iomanip>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); (i) <= (int)(b); i++)
#define VEC(type, c, n) \
std::vector<type> c(n); \
for (auto &i : c) \
std::cin >> i;
#define vec(type, n) vector<type>(n)
#define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
vector<int> bitSearch(int bit, int n) {
vector<int> S, False(1, -1);
rep(i, n) if (bit & (1 << i)) S.push_back(i);
return S;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
ll gcd(ll a, ll b) {
if (a % b == 0)
return b;
else
return gcd(b, a % b);
}
const ll INF = 1e9;
int dp[1005][10005];
int main() {
int h, n;
cin >> h >> n;
vector<int> attack(n), cost(n);
rep(i, n) { cin >> attack[i] >> cost[i]; }
rep(i, n + 10) rep(j, h + 10) dp[i][j] = INF;
rep(i, n) dp[i][0] = 0;
rep(i, n) {
rep(j, h + 1) {
dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
dp[i + 1][min(j + attack[i], h)] =
min(dp[i + 1][min(j + attack[i], h)], dp[i + 1][j] + cost[i]);
}
}
cout << dp[n][h] << endl;
} | #include <iostream>
#include <stdio.h>
// #include <bits/stdc++.h>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <float.h>
#include <iomanip>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; (i) < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); (i) <= (int)(b); i++)
#define VEC(type, c, n) \
std::vector<type> c(n); \
for (auto &i : c) \
std::cin >> i;
#define vec(type, n) vector<type>(n)
#define vvec(m, n) vector<vector<int>>(int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
vector<int> bitSearch(int bit, int n) {
vector<int> S, False(1, -1);
rep(i, n) if (bit & (1 << i)) S.push_back(i);
return S;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
ll gcd(ll a, ll b) {
if (a % b == 0)
return b;
else
return gcd(b, a % b);
}
const ll INF = 1e9;
ll dp[1010][10100];
int main() {
int h, n;
cin >> h >> n;
vector<int> attack(n), cost(n);
rep(i, n) { cin >> attack[i] >> cost[i]; }
rep(i, n + 10) rep(j, h + 10) dp[i][j] = INF;
rep(i, n) dp[i][0] = 0;
rep(i, n) {
rep(j, h + 1) {
dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
dp[i + 1][min(j + attack[i], h)] =
min(dp[i + 1][min(j + attack[i], h)], dp[i + 1][j] + cost[i]);
}
}
cout << dp[n][h] << endl;
} | replace | 53 | 54 | 53 | 54 | 0 | |
p02787 | C++ | Runtime Error | #include <bits/stdc++.h>
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
using namespace std;
int D[10001];
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
TEST(freopen("input.txt", "r", stdin));
TEST(freopen("output.txt", "w", stdout));
TEST(freopen("debug.txt", "w", stderr));
int H, N;
cin >> H >> N;
memset(D, 0x7f, sizeof(D));
D[0] = 0;
while (N--) {
int A, B;
cin >> A >> B;
for (int i = A; i <= 30000; i++)
D[i] = min(D[i], D[i - A] + B);
for (int i = 30000; i > 0; i--)
D[i - 1] = min(D[i - 1], D[i]);
}
cout << D[H] << '\n';
return 0;
} | #include <bits/stdc++.h>
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
using namespace std;
int D[30001];
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
TEST(freopen("input.txt", "r", stdin));
TEST(freopen("output.txt", "w", stdout));
TEST(freopen("debug.txt", "w", stderr));
int H, N;
cin >> H >> N;
memset(D, 0x7f, sizeof(D));
D[0] = 0;
while (N--) {
int A, B;
cin >> A >> B;
for (int i = A; i <= 30000; i++)
D[i] = min(D[i], D[i - A] + B);
for (int i = 30000; i > 0; i--)
D[i - 1] = min(D[i - 1], D[i]);
}
cout << D[H] << '\n';
return 0;
} | replace | 12 | 13 | 12 | 13 | -11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.