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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K, Q;
cin >> N >> K >> Q;
int A[N];
int index;
for (int i = 0; i < Q; i++) {
A[i] = 0;
}
for (int i = 0; i < Q; i++) {
cin >> index;
A[index - 1] += 1;
}
for (int i = 0; i < N; i++) {
if (K - (Q - A[i]) > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K, Q;
cin >> N >> K >> Q;
int A[N];
int index;
for (int i = 0; i < N; i++) {
A[i] = 0;
}
for (int i = 0; i < Q; i++) {
cin >> index;
A[index - 1] += 1;
}
for (int i = 0; i < N; i++) {
if (K - (Q - A[i]) > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
} | replace | 8 | 9 | 8 | 9 | 0 | |
p02911 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main() {
int n, k, q;
cin >> n >> k >> q;
vector<int> a;
for (int i = 0; i < q; i++) {
int val;
cin >> val;
a.push_back(val);
}
vector<ll> pt(n);
fill(pt.begin(), pt.end(), k - q);
for (auto &e : a) {
pt.at(e)++;
}
for (const auto &e : pt) {
cout << (e > 0 ? "Yes" : "No") << endl;
}
return 0;
}
| #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int main() {
int n, k, q;
cin >> n >> k >> q;
vector<int> a;
for (int i = 0; i < q; i++) {
int val;
cin >> val;
a.push_back(val);
}
vector<ll> pt(n);
fill(pt.begin(), pt.end(), k - q);
for (auto &e : a) {
pt.at(e - 1)++;
}
for (const auto &e : pt) {
cout << (e > 0 ? "Yes" : "No") << endl;
}
return 0;
}
| replace | 21 | 22 | 21 | 22 | 0 | |
p02911 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long int;
int main(void) {
ll n, k, q;
cin >> n >> k >> q;
vector<int> a(n);
rep(i, q) cin >> a[i];
vector<int> p(n, k - q);
rep(i, q) p[a[i] - 1]++;
rep(i, n) { p[i] > 0 ? cout << "Yes" << endl : cout << "No" << endl; }
} | #include <algorithm>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long int;
int main(void) {
ll n, k, q;
cin >> n >> k >> q;
vector<int> a(q);
rep(i, q) cin >> a[i];
vector<int> p(n, k - q);
rep(i, q) p[a[i] - 1]++;
rep(i, n) { p[i] > 0 ? cout << "Yes" << endl : cout << "No" << endl; }
} | replace | 11 | 12 | 11 | 12 | 0 | |
p02911 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k, q, a;
cin >> n >> k >> q;
vector<long long> count(n, k);
for (int i = 0; i < q; ++i) {
cin >> a;
count.at(a - 1) += 1;
for (int j = 0; j < n; ++j) {
count.at(j) -= 1;
}
}
for (int i = 0; i < n; ++i) {
if (count.at(i) <= 0)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k, q, a;
cin >> n >> k >> q;
vector<long long> count(n, k);
for (int i = 0; i < q; ++i) {
cin >> a;
count.at(a - 1) += 1;
}
for (int j = 0; j < n; ++j) {
count.at(j) -= 1 * q;
}
for (int i = 0; i < n; ++i) {
if (count.at(i) <= 0)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
} | replace | 10 | 13 | 10 | 13 | TLE | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll N, K, Q;
cin >> N >> K >> Q;
vector<ll> A;
for (ll i = 0; i < Q; ++i) {
ll a;
cin >> a;
A[a - 1]++;
}
for (ll i = 0; i < N; ++i) {
if (K - (Q - A[i]) > 0) {
printf("Yes\n");
} else {
printf("No\n");
}
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll N, K, Q;
cin >> N >> K >> Q;
vector<ll> A(N, 0);
for (ll i = 0; i < Q; ++i) {
ll a;
cin >> a;
A[a - 1]++;
}
for (ll i = 0; i < N; ++i) {
if (K - (Q - A[i]) > 0) {
printf("Yes\n");
} else {
printf("No\n");
}
}
return 0;
}
| replace | 6 | 7 | 6 | 7 | -11 | |
p02911 | C++ | Runtime Error | #include <iostream>
#include <vector>
using namespace std;
int main() {
int n, k, q;
cin >> n >> k >> q;
vector<int> player(k, 0);
for (int i = 0; i < q; i++) {
int a;
cin >> a;
player[a - 1]++;
}
for (int i = 0; i < n; i++) {
if (0 < player[i] + k - q) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
return 0;
}
| #include <iostream>
#include <vector>
using namespace std;
int main() {
int n, k, q;
cin >> n >> k >> q;
vector<int> player(n, 0);
for (int i = 0; i < q; i++) {
int a;
cin >> a;
player[a - 1]++;
}
for (int i = 0; i < n; i++) {
if (0 < player[i] + k - q) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
return 0;
}
| replace | 10 | 11 | 10 | 11 | 0 | |
p02911 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define vint vector<int>
#define rep(x, y) for (int i = x; i < y; i++)
#define REP(x, y) for (int j = x; j < y; j++)
#define all(x) x.begin(), x.end()
#define pb() push_back()
#define mod 100000007
#define elif else if
#define str string
// main
signed main() {
int N, M, O, Q, count = 0, count2 = 0, count3 = 0;
double D = 0;
int c = 'A' - 'a';
// char C;
str S, T;
cin >> N >> M >> O;
vint A(O);
vint P(N);
rep(0, N) P[i] = M;
rep(0, O) cin >> A[i];
rep(0, O) {
REP(0, N) {
if (j + 1 != A[i]) {
P[j] -= 1;
}
}
}
rep(0, N) P[i] > 0 ? cout << "Yes" << endl : cout << "No" << endl;
}
| #include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define vint vector<int>
#define rep(x, y) for (int i = x; i < y; i++)
#define REP(x, y) for (int j = x; j < y; j++)
#define all(x) x.begin(), x.end()
#define pb() push_back()
#define mod 100000007
#define elif else if
#define str string
// main
signed main() {
int N, M, O, Q, count = 0, count2 = 0, count3 = 0;
double D = 0;
int c = 'A' - 'a';
// char C;
str S, T;
cin >> N >> M >> O;
vint A(O);
vint P(N);
rep(0, N) P[i] = M;
rep(0, O) cin >> A[i];
rep(0, O) P[A[i] - 1] += 1;
rep(0, N) P[i] > O ? cout << "Yes" << endl : cout << "No" << endl;
}
| replace | 24 | 32 | 24 | 26 | TLE | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K, Q, i, j = 0;
cin >> N >> K >> Q;
vector<int> P(N, K - Q);
vector<int> Ans(Q);
for (i = 0; i < Q; i++)
cin >> Ans.at(i);
for (i = 0; i < Q; i++)
P.at(Ans.at(i))++;
for (i = 0; i < N; i++) {
if (P.at(i) <= 0)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K, Q, i, j = 0;
cin >> N >> K >> Q;
vector<int> P(N, K - Q);
vector<int> Ans(Q);
for (i = 0; i < Q; i++)
cin >> Ans.at(i);
for (i = 0; i < Q; i++)
P.at(Ans.at(i) - 1)++;
for (i = 0; i < N; i++) {
if (P.at(i) <= 0)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
return 0;
} | replace | 12 | 13 | 12 | 13 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, q;
cin >> n >> k >> q;
vector<int> a(n + 1);
for (int i = 1; i <= q; i++) {
cin >> a[i];
}
vector<int> times(n + 1, 0);
for (int i = 1; i <= q; i++) {
times[a[i]] += 1;
}
for (int i = 1; i <= n; i++) {
if (k - (q - times[i]) > 0)
cout << "Yes" << endl;
if (k - (q - times[i]) <= 0)
cout << "No" << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, q;
cin >> n >> k >> q;
vector<int> a(q + 1);
for (int i = 1; i <= q; i++) {
cin >> a[i];
}
vector<int> times(n + 1, 0);
for (int i = 1; i <= q; i++) {
times[a[i]] += 1;
}
for (int i = 1; i <= n; i++) {
if (k - (q - times[i]) > 0)
cout << "Yes" << endl;
if (k - (q - times[i]) <= 0)
cout << "No" << endl;
}
return 0;
} | replace | 7 | 8 | 7 | 8 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
int main() {
int n, k, q;
int point[10005];
cin >> n >> k >> q;
rep(i, n + 1) point[i] = 0;
rep(i, q) {
int temp;
cin >> temp;
point[temp + 1]++;
}
for (int i = 1; i < n + 1; i++) {
cout << (k - (q - point[i + 1]) > 0 ? "Yes" : "No") << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
int main() {
int n, k, q;
int point[100005];
cin >> n >> k >> q;
rep(i, n + 1) point[i] = 0;
rep(i, q) {
int temp;
cin >> temp;
point[temp + 1]++;
}
for (int i = 1; i < n + 1; i++) {
cout << (k - (q - point[i + 1]) > 0 ? "Yes" : "No") << endl;
}
return 0;
}
| replace | 7 | 8 | 7 | 8 | 0 | |
p02911 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define MIN(a, b) (((a) <= (b)) ? (a) : (b))
#define MAX(a, b) (((a) >= (b)) ? (a) : (b))
#define ll long long int
using namespace std;
int main() {
int n, p, q;
cin >> n >> p >> q;
int qq[q];
rep(i, q) cin >> qq[i];
rep(i, q) qq[i]--;
int a[n];
rep(i, n) a[i] = p;
rep(i, q) rep(j, n) if (j != qq[i]) a[j]--;
rep(i, n) {
if (a[i] > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define MIN(a, b) (((a) <= (b)) ? (a) : (b))
#define MAX(a, b) (((a) >= (b)) ? (a) : (b))
#define ll long long int
using namespace std;
int main() {
int n, p, q;
cin >> n >> p >> q;
int qq[q];
rep(i, q) cin >> qq[i];
rep(i, q) qq[i]--;
int a[n];
rep(i, n) a[i] = p;
rep(i, q) a[qq[i]]++;
rep(i, n) a[i] -= q;
rep(i, n) {
if (a[i] > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
} | replace | 15 | 16 | 15 | 17 | TLE | |
p02911 | C++ | Runtime Error | #include <iostream>
using namespace std;
int p[10005], a[10005];
int main() {
int n, k, q;
cin >> n >> k >> q;
for (int i = 1; i <= n; i++) {
p[i] = k - q;
}
for (int i = 1; i <= q; i++) {
cin >> a[i];
}
for (int i = 1; i <= q; i++) {
p[a[i]]++;
}
for (int i = 1; i <= n; i++) {
if (p[i] < 1) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
return 0;
}
| #include <iostream>
using namespace std;
int p[100005], a[100005];
int main() {
int n, k, q;
cin >> n >> k >> q;
for (int i = 1; i <= n; i++) {
p[i] = k - q;
}
for (int i = 1; i <= q; i++) {
cin >> a[i];
}
for (int i = 1; i <= q; i++) {
p[a[i]]++;
}
for (int i = 1; i <= n; i++) {
if (p[i] < 1) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
return 0;
}
| replace | 2 | 3 | 2 | 3 | 0 | |
p02911 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;
void P(int x) { cout << x << endl; }
void P(long x) { cout << x << endl; }
void P(double x) { cout << x << endl; }
void P(ll x) { cout << x << endl; }
void P(string x) { cout << x << endl; }
void P(char x) { cout << x << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
int n, k, q;
cin >> n >> k >> q;
vector<int> a(n);
rep(i, n) { a[n] = 0; }
rep(i, q) {
int tmp;
cin >> tmp;
a[tmp - 1]++;
}
rep(i, n) {
if (k - (q - a[i]) > 0)
Yes;
else
No;
}
return 0;
}
| #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;
void P(int x) { cout << x << endl; }
void P(long x) { cout << x << endl; }
void P(double x) { cout << x << endl; }
void P(ll x) { cout << x << endl; }
void P(string x) { cout << x << endl; }
void P(char x) { cout << x << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
int n, k, q;
cin >> n >> k >> q;
vector<int> a(n);
rep(i, q) {
int tmp;
cin >> tmp;
a[tmp - 1]++;
}
rep(i, n) {
if (k - (q - a[i]) > 0)
Yes;
else
No;
}
return 0;
}
| delete | 38 | 39 | 38 | 38 | -6 | Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)
|
p02911 | C++ | Time Limit Exceeded | #include <stdio.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(void) {
int N, K, Q;
scanf("%d %d %d", &N, &K, &Q);
vector<int> A(Q);
rep(i, Q) { scanf("%d", &A[i]); }
vector<int> score(N);
rep(i, N) score[i] = K - Q;
rep(i, Q) {
rep(j, N) {
if (j + 1 == A[i]) {
score[j]++;
break;
}
}
}
rep(i, N) {
if (score[i] <= 0)
printf("No\n");
else
printf("Yes\n");
}
return 0;
} | #include <stdio.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(void) {
int N, K, Q;
scanf("%d %d %d", &N, &K, &Q);
vector<int> A(Q);
rep(i, Q) { scanf("%d", &A[i]); }
vector<int> score(N);
rep(i, N) score[i] = K - Q;
rep(i, Q) { score[A[i] - 1]++; }
rep(i, N) {
if (score[i] <= 0)
printf("No\n");
else
printf("Yes\n");
}
return 0;
} | replace | 16 | 24 | 16 | 17 | TLE | |
p02911 | C++ | Runtime Error | #include <iostream>
using namespace std;
int main() {
int n, m, k, score[10005], t;
while (cin >> n >> m >> k) {
for (int i = 1; i <= n; i++)
score[i] = m;
for (int i = 1; i <= k; i++)
cin >> t, score[t]++;
for (int i = 1; i <= n; i++) {
score[i] -= k;
if (score[i] > 0)
cout << "Yes\n";
else
cout << "No\n";
}
}
} | #include <iostream>
using namespace std;
int main() {
long long n, m, k, score[100005], t;
while (cin >> n >> m >> k) {
for (int i = 1; i <= n; i++)
score[i] = m;
for (int i = 1; i <= k; i++)
cin >> t, score[t]++;
for (int i = 1; i <= n; i++) {
score[i] -= k;
if (score[i] > 0)
cout << "Yes\n";
else
cout << "No\n";
}
}
} | replace | 3 | 4 | 3 | 4 | 0 | |
p02911 | Python | Time Limit Exceeded | def main():
N, K, Q, *A = map(int, open(0).read().split())
A = [K + A.count(i) for i in range(1, N + 1)]
print("\n".join(["Yes" if Q < a else "No" for a in A]))
return
main()
| def main():
N, K, Q, *A = map(int, open(0).read().split())
ans = [0] * N
for a in A:
ans[a - 1] += 1
print("\n".join(["Yes" if Q < K + a else "No" for a in ans]))
return
main()
| replace | 2 | 4 | 2 | 6 | TLE | |
p02911 | Python | Runtime Error | n, k, q = map(int, input().split())
a = []
for i in range(q):
a[i] = int(input()) - 1
score = [0 for _ in range(n)]
for a_i in a:
score[a_i] += 1
for i in range(n):
result = k - q + score[i]
print("Yes" if result > 0 else "No")
| n, k, q = map(int, input().split())
a = []
for i in range(q):
a.append(int(input()) - 1)
score = [0 for _ in range(n)]
for a_i in a:
score[a_i] += 1
for i in range(n):
result = k - q + score[i]
print("Yes" if result > 0 else "No")
| replace | 3 | 4 | 3 | 4 | IndexError: list assignment index out of range | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02911/Python/s560201752.py", line 4, in <module>
a[i] = int(input()) - 1
IndexError: list assignment index out of range
|
p02911 | Python | Time Limit Exceeded | N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
points = [K for _ in range(N)]
for i in range(Q):
points[A[i] - 1] += 1
for j in range(N):
points[j] -= 1
for j in range(N):
if points[j] >= 1:
print("Yes")
else:
print("No")
| N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
points = [K for _ in range(N)]
for i in range(Q):
points[A[i] - 1] += 1
for j in range(N):
points[j] -= Q
for j in range(N):
if points[j] >= 1:
print("Yes")
else:
print("No")
| replace | 7 | 9 | 7 | 10 | TLE | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(Q);
vector<int> cnt(N);
for (int i = 0; i < N; i++) {
cnt[i] = K - Q;
}
for (int i = 0; i < Q; i++) {
cin >> A[i];
cnt[A[i] - 1]++;
}
for (int i = 0; i < N; i++) {
if (A[i] > 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(Q);
vector<int> cnt(N);
for (int i = 0; i < N; i++) {
cnt[i] = K - Q;
}
for (int i = 0; i < Q; i++) {
cin >> A[i];
cnt[A[i] - 1]++;
}
for (int i = 0; i < N; i++) {
if (cnt[i] > 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
} | replace | 16 | 17 | 16 | 17 | 0 | |
p02911 | C++ | Runtime Error | #include <stdio.h>
int main() {
int N, K, Q;
int i;
int tmp;
static int array[10000];
scanf("%d %d %d", &N, &K, &Q);
for (i = 0; i < N; i++) {
array[i] = K - Q;
}
for (i = 0; i < Q; i++) {
scanf("%d", &tmp);
array[tmp - 1]++;
}
for (i = 0; i < N; i++) {
if (array[i] <= 0) {
printf("No\n");
} else {
printf("Yes\n");
}
}
return 0;
} | #include <stdio.h>
int main() {
int N, K, Q;
int i;
int tmp;
static int array[100000];
scanf("%d %d %d", &N, &K, &Q);
for (i = 0; i < N; i++) {
array[i] = K - Q;
}
for (i = 0; i < Q; i++) {
scanf("%d", &tmp);
array[tmp - 1]++;
}
for (i = 0; i < N; i++) {
if (array[i] <= 0) {
printf("No\n");
} else {
printf("Yes\n");
}
}
return 0;
} | replace | 6 | 7 | 6 | 7 | 0 | |
p02911 | C++ | Runtime Error | #include <iostream>
#include <string>
using namespace std;
int main() {
long N, K, Q, B[10500] = {0}, A[10500];
cin >> N >> K >> Q;
for (int i = 0; i < Q; i++) {
cin >> A[i];
}
if (Q < K) {
for (int i = 0; i < N; i++) {
cout << "Yes" << endl;
}
} else {
for (int i = 0; i < Q; i++) {
B[A[i]]++;
}
for (int i = 0; i < N; i++) {
if (B[i + 1] <= Q - K) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
}
return 0;
} | #include <iostream>
#include <string>
using namespace std;
int main() {
long N, K, Q, B[100500] = {0}, A[100500] = {0};
cin >> N >> K >> Q;
for (int i = 0; i < Q; i++) {
cin >> A[i];
}
if (Q < K) {
for (int i = 0; i < N; i++) {
cout << "Yes" << endl;
}
} else {
for (int i = 0; i < Q; i++) {
B[A[i]]++;
}
for (int i = 0; i < N; i++) {
if (B[i + 1] <= Q - K) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
}
return 0;
} | replace | 5 | 6 | 5 | 6 | 0 | |
p02911 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <fstream>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
const long INF = (1l << 30);
const long LINF = (1l << 60);
long n, k, q;
long pnt[10005];
int main() {
scanf("%ld%ld%ld", &n, &k, &q);
for (int i = 0; i < q; i++) {
long a;
scanf("%ld", &a);
a--;
pnt[a]++;
}
for (int i = 0; i < n; i++) {
pnt[i] += k - q;
if (pnt[i] <= 0) {
printf("No\n");
} else {
printf("Yes\n");
}
}
}
| #include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <fstream>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
const long INF = (1l << 30);
const long LINF = (1l << 60);
long n, k, q;
long pnt[100005];
int main() {
scanf("%ld%ld%ld", &n, &k, &q);
for (int i = 0; i < q; i++) {
long a;
scanf("%ld", &a);
a--;
pnt[a]++;
}
for (int i = 0; i < n; i++) {
pnt[i] += k - q;
if (pnt[i] <= 0) {
printf("No\n");
} else {
printf("Yes\n");
}
}
}
| replace | 25 | 26 | 25 | 26 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, q;
long long k;
cin >> n >> k >> q;
long long p[10010] = {0};
for (long long i = 0; i < q; i++) {
long long a;
cin >> a;
a--;
p[a]++;
}
for (long long i = 0; i < n; i++) {
if (k - (q - p[i]) <= 0)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, q;
long long k;
cin >> n >> k >> q;
long long p[100100] = {0};
for (long long i = 0; i < q; i++) {
long long a;
cin >> a;
a--;
p[a]++;
}
for (long long i = 0; i < n; i++) {
if (k - (q - p[i]) <= 0)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
}
| replace | 8 | 9 | 8 | 9 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define all(a) a.begin(), a.end()
#define P pair<long long, long long>
#define double long double
using namespace std;
// 桁
int kt(int a) {
double b = a;
b = log10(b);
int c = b;
return c + 1;
}
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;
}
signed main() {
int a, b, c;
cin >> a >> b >> c;
vector<int> d(c);
rep(i, c) cin >> d.at(i);
vector<int> e(a, b - c);
rep(i, c) { e.at(d.at(i))++; }
rep(i, a) {
if (e.at(i) > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
} | #include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define all(a) a.begin(), a.end()
#define P pair<long long, long long>
#define double long double
using namespace std;
// 桁
int kt(int a) {
double b = a;
b = log10(b);
int c = b;
return c + 1;
}
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;
}
signed main() {
int a, b, c;
cin >> a >> b >> c;
vector<int> d(c);
rep(i, c) cin >> d.at(i);
vector<int> e(a, b - c);
rep(i, c) { e.at(d.at(i) - 1)++; }
rep(i, a) {
if (e.at(i) > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
} | replace | 55 | 56 | 55 | 56 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n, k, q;
cin >> n >> k >> q;
vector<int> a(q, 0);
for (int i = 0; i < q; i++) {
int temp;
cin >> temp;
a[temp - 1]++;
}
for (int i = 0; i < n; i++) {
if (k - (q - a[i]) <= 0) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n, k, q;
cin >> n >> k >> q;
vector<int> a(n, 0);
for (int i = 0; i < q; i++) {
int temp;
cin >> temp;
a[temp - 1]++;
}
for (int i = 0; i < n; i++) {
if (k - (q - a[i]) <= 0) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
return 0;
}
| replace | 8 | 9 | 8 | 9 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(Q);
for (int i = 0; i < Q; i++) {
int x;
cin >> x;
A.at(x - 1)++;
}
for (int i = 0; i < N; i++) {
string S = Q - A.at(i) < K ? "Yes" : "No";
cout << S << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(N);
for (int i = 0; i < Q; i++) {
int x;
cin >> x;
A.at(x - 1)++;
}
for (int i = 0; i < N; i++) {
string S = Q - A.at(i) < K ? "Yes" : "No";
cout << S << endl;
}
}
| replace | 5 | 6 | 5 | 6 | -6 | terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 4) >= this->size() (which is 4)
|
p02911 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define pow(x) x *x
int main() {
int N, Q, i, j;
long long K;
int who, A[10010] = {0};
int border;
cin >> N >> K >> Q;
REP(i, Q) {
cin >> who;
A[--who]++;
}
border = Q - K;
REP(i, N) {
if (A[i] > border) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
/*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||- \
| | \\\ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pass System Test!
*/ | #include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define pow(x) x *x
int main() {
int N, Q, i, j;
long long K;
int who, A[100100] = {0};
long long border;
cin >> N >> K >> Q;
REP(i, Q) {
cin >> who;
A[--who]++;
}
border = Q - K;
REP(i, N) {
if (A[i] > border) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
/*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \\| |// `.
/ \\||| : |||// \
/ _||||| -:- |||||- \
| | \\\ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pass System Test!
*/ | replace | 14 | 16 | 14 | 16 | 0 | |
p02911 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(Q);
vector<int> player(N);
rep(i, Q) { cin >> A.at(i); }
rep(i, N) { player.at(i) = K; }
rep(j, N) {
rep(i, Q) {
if (A.at(i) - 1 == j) {
} else {
player.at(j)--;
}
}
}
rep(i, N) {
if (player.at(i) <= 0) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(Q);
vector<int> player(N);
rep(i, Q) { cin >> A.at(i); }
rep(i, N) { player.at(i) = K - Q; }
rep(i, Q) { player.at(A.at(i) - 1)++; }
rep(i, N) {
if (player.at(i) <= 0) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
return 0;
} | replace | 10 | 19 | 10 | 12 | TLE | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, q;
cin >> n >> k >> q;
vector<int> a(n, 0);
int x;
for (int i = 0; i < q; i++) {
cin >> x;
x--;
a[x]++;
}
int sum = accumulate(a.begin(), a.end(), 0);
for (int i = 0; i < q; i++) {
cout << ((sum - a[i] < k) ? "Yes" : "No") << '\n';
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, q;
cin >> n >> k >> q;
vector<int> a(n, 0);
int x;
for (int i = 0; i < q; i++) {
cin >> x;
x--;
a[x]++;
}
for (int i = 0; i < n; i++) {
cout << ((q - a[i] < k) ? "Yes" : "No") << '\n';
}
return 0;
} | replace | 14 | 17 | 14 | 16 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(Q);
rep(i, Q) {
int x;
cin >> x;
--x;
A[i] = x;
}
vector<int> point(N, K - Q);
rep(i, Q) { point[A[i]]++; }
rep(i, Q) {
if (point[i] > 0)
cout << "Yes\n";
else
cout << "No\n";
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(Q);
rep(i, Q) {
int x;
cin >> x;
--x;
A[i] = x;
}
vector<int> point(N, K - Q);
rep(i, Q) { point[A[i]]++; }
rep(i, N) {
if (point[i] > 0)
cout << "Yes\n";
else
cout << "No\n";
}
return 0;
}
| replace | 19 | 20 | 19 | 20 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
/*int main(){//B
string S;
cin>>S;
rep(i,0,S.size()){
if(i%2==0){
if(S[i]!='R'&&S[i]!='U'&&S[i]!='D') {
cout<<"No"<<endl;
return 0;
}
}
if(i%2!=0){
if(S[i]!='L'&&S[i]!='U'&&S[i]!='D'){
cout<<"No"<<endl;
return 0;
}
}
}
cout<<"Yes"<<endl;
return 0;
}*/
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(N, K - Q);
// vector<int> B(Q);
int c = N;
rep(i, 0, Q) {
int b;
cin >> b;
if (b != i + 1)
A[i]++;
}
rep(i, 0, N) {
if (A[i] > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
/*int main(){//B
string S;
cin>>S;
rep(i,0,S.size()){
if(i%2==0){
if(S[i]!='R'&&S[i]!='U'&&S[i]!='D') {
cout<<"No"<<endl;
return 0;
}
}
if(i%2!=0){
if(S[i]!='L'&&S[i]!='U'&&S[i]!='D'){
cout<<"No"<<endl;
return 0;
}
}
}
cout<<"Yes"<<endl;
return 0;
}*/
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(N, K - Q);
// vector<int> B(Q);
int c = N;
rep(i, 0, Q) {
int b;
cin >> b;
A[b - 1]++;
}
rep(i, 0, N) {
if (A[i] > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
} | replace | 34 | 36 | 34 | 35 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll N, K, Q;
cin >> N >> K >> Q;
vector<int> score(N);
for (ll i = 0; i < N; i++) {
score.at(i) = K - Q;
}
for (ll i = 0; i < Q; i++) {
int a;
cin >> a;
score.at(a)++;
}
for (ll i = 0; i < N; i++) {
if (score.at(i) > 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll N, K, Q;
cin >> N >> K >> Q;
vector<int> score(N);
for (ll i = 0; i < N; i++) {
score.at(i) = K - Q;
}
for (ll i = 0; i < Q; i++) {
int a;
cin >> a;
score.at(a - 1)++;
}
for (ll i = 0; i < N; i++) {
if (score.at(i) > 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
return 0;
} | replace | 17 | 18 | 17 | 18 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 5e4 + 10, MAXM = 1e6 + 10;
const int INF = ~(1 << 31), MOD = 1e9 + 7;
int a[MAXN];
int main() {
int n, m, q;
scanf("%d%d%d", &n, &m, &q);
for (int i = 1; i <= q; i++) {
int temp;
scanf("%d", &temp);
a[temp]++;
}
for (int i = 1; i <= n; i++)
if (a[i] + m - q > 0)
puts("Yes");
else
puts("No");
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 1e5 + 10, MAXM = 1e6 + 10;
const int INF = ~(1 << 31), MOD = 1e9 + 7;
int a[MAXN];
int main() {
int n, m, q;
scanf("%d%d%d", &n, &m, &q);
for (int i = 1; i <= q; i++) {
int temp;
scanf("%d", &temp);
a[temp]++;
}
for (int i = 1; i <= n; i++)
if (a[i] + m - q > 0)
puts("Yes");
else
puts("No");
return 0;
}
| replace | 4 | 5 | 4 | 5 | 0 | |
p02911 | C++ | Time Limit Exceeded | #include <iostream>
#include <vector>
using namespace std;
int main() { // 参加者のポイントをQ減らし、正解者にポ
// イントを増やしていく実装
int N, K, Q;
cin >> N >> K >> Q;
vector<int> s(N, K - Q); // あらかじめ参加者のポイント
// を減らしておく
vector<int> A(Q);
for (int i = 0; i < Q; i++)
cin >> A.at(i);
for (int i = 0; i < Q; i++) {
for (int j = 0; j < N; j++) {
if ((j + 1) == A.at(i)) {
s.at(j)++;
}
}
}
for (int i = 0; i < N; i++) {
if (s.at(i) <= 0)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
} | #include <iostream>
#include <vector>
using namespace std;
int main() { // 参加者のポイントをQ減らし、正解者にポ
// イントを増やしていく実装
int N, K, Q;
cin >> N >> K >> Q;
vector<int> s(N, K - Q); // あらかじめ参加者のポイント
// を減らしておく
vector<int> A(Q);
for (int i = 0; i < Q; i++)
cin >> A.at(i);
for (int i = 0; i < Q; i++) {
s.at(A.at(i) - 1)++;
}
for (int i = 0; i < N; i++) {
if (s.at(i) <= 0)
cout << "No" << endl;
else
cout << "Yes" << endl;
}
} | replace | 14 | 19 | 14 | 15 | TLE | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
int K;
int Q;
cin >> N >> K >> Q;
int num = Q - K + 1;
int num2;
vector<int> A(Q);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
vector<int> B(N);
if (Q - K < 0) {
for (int i = 0; i < N; ++i) {
cout << "Yes" << endl;
}
} else {
for (int j = 0; j < Q; ++j) {
num2 = A[j] - 1;
B[num2] = B[num2] + 1;
}
for (int i = 0; i < N; ++i) {
if (B[i] >= num) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
int K;
int Q;
cin >> N >> K >> Q;
int num = Q - K + 1;
int num2;
vector<int> A(Q);
for (int i = 0; i < Q; ++i) {
cin >> A[i];
}
vector<int> B(N);
if (Q - K < 0) {
for (int i = 0; i < N; ++i) {
cout << "Yes" << endl;
}
} else {
for (int j = 0; j < Q; ++j) {
num2 = A[j] - 1;
B[num2] = B[num2] + 1;
}
for (int i = 0; i < N; ++i) {
if (B[i] >= num) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
}
| replace | 14 | 15 | 14 | 15 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, k, q;
cin >> n >> k >> q;
vector<ll> vec(n, k - q);
ll tmp;
for (int i = 0; i < q; i++) {
cin >> tmp;
vec.at(tmp)++;
}
for (int i = 0; i < n; i++) {
if (vec.at(i) > 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, k, q;
cin >> n >> k >> q;
vector<ll> vec(n, k - q);
ll tmp;
for (int i = 0; i < q; i++) {
cin >> tmp;
vec.at(tmp - 1)++;
}
for (int i = 0; i < n; i++) {
if (vec.at(i) > 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
| replace | 11 | 12 | 11 | 12 | 0 | |
p02911 | C++ | Runtime Error | #include <iostream>
#include <string>
using namespace std;
int main() {
long long n, k, q, line;
long long *a, *b;
cin >> n;
cin >> k;
cin >> q;
line = q - k + 1;
a = new long long[q];
b = new long long[n];
for (int i = 0; i < n; i++) {
b[i] = 0;
}
for (int i = 0; i < q; i++) {
cin >> a[i];
b[a[i] - 1]++;
}
for (int i = 0; i < q; i++) {
if (b[i] >= line) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
} | #include <iostream>
#include <string>
using namespace std;
int main() {
long long n, k, q, line;
long long *a, *b;
cin >> n;
cin >> k;
cin >> q;
line = q - k + 1;
a = new long long[q];
b = new long long[n];
for (int i = 0; i < n; i++) {
b[i] = 0;
}
for (int i = 0; i < q; i++) {
cin >> a[i];
b[a[i] - 1]++;
}
for (int i = 0; i < n; i++) {
if (b[i] >= line) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
} | replace | 21 | 22 | 21 | 22 | 0 | |
p02911 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
ll n, k, q;
cin >> n >> k >> q;
vector<ll> a(q);
rep(i, q) cin >> a[i];
vector<ll> pa(n);
rep(i, n) pa[i] = k;
rep(i, q) {
rep(j, n) {
if ((a[i] - 1) != j)
pa[j]--;
}
// rep(i,n) cout<<pa[i]<<" ";
// cout<<endl;
}
rep(i, n) {
if (pa[i] > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
ll n, k, q;
cin >> n >> k >> q;
vector<ll> a(q);
rep(i, q) cin >> a[i];
vector<ll> pa(n);
rep(i, n) pa[i] = k - q;
rep(i, q) { pa[a[i] - 1]++; }
rep(i, n) {
if (pa[i] > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
| replace | 12 | 21 | 12 | 14 | TLE | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(N);
for (int i = 0; i < Q; i++) {
cin >> A.at(i);
}
vector<int> ans(N);
for (int i = 0; i < N; i++) {
ans.at(i) = K - Q;
}
for (int i = 0; i < Q; i++) {
ans.at(A.at(i) - 1)++;
}
for (int i = 0; i < N; i++) {
if (ans.at(i) > 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(Q);
for (int i = 0; i < Q; i++) {
cin >> A.at(i);
}
vector<int> ans(N);
for (int i = 0; i < N; i++) {
ans.at(i) = K - Q;
}
for (int i = 0; i < Q; i++) {
ans.at(A.at(i) - 1)++;
}
for (int i = 0; i < N; i++) {
if (ans.at(i) > 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
}
| replace | 6 | 7 | 6 | 7 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(N);
vector<int> B(N);
vector<string> C(N);
for (int i = 0; i < N; i++) {
B.at(i) = B.at(i) + K - Q;
C.at(i) = "Yes";
}
for (int i = 0; i < Q; i++) {
cin >> A.at(i);
B.at(A.at(i) - 1)++;
}
for (int i = 0; i < N; i++) {
if (B.at(i) <= 0) {
C.at(i) = "No";
}
cout << C.at(i) << endl;
}
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K, Q;
cin >> N >> K >> Q;
vector<int> A(Q);
vector<int> B(N);
vector<string> C(N);
for (int i = 0; i < N; i++) {
B.at(i) = B.at(i) + K - Q;
C.at(i) = "Yes";
}
for (int i = 0; i < Q; i++) {
cin >> A.at(i);
B.at(A.at(i) - 1)++;
}
for (int i = 0; i < N; i++) {
if (B.at(i) <= 0) {
C.at(i) = "No";
}
cout << C.at(i) << endl;
}
}
| replace | 6 | 7 | 6 | 7 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
unsigned int n, q;
unsigned long long int k;
cin >> n >> k >> q;
// cout << n << ',' << k << ',' << q << endl;
vector<unsigned int> a(q);
for (unsigned int i = 0; i < q; ++i) {
cin >> a.at(i);
}
// cout << n << ',' << k << ',' << q << endl;
vector<int> score(n, k - q);
for (unsigned int i = 0; i < q; ++i) {
score.at(a.at(i))++;
}
for (unsigned int i = 0; i < n; ++i) {
// cout << "i: " << i << ", score[" << i << "]: " << score.at(i) << endl;
if (score.at(i) <= 0) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
unsigned int n, q;
unsigned long long int k;
cin >> n >> k >> q;
// cout << n << ',' << k << ',' << q << endl;
vector<unsigned int> a(q);
for (unsigned int i = 0; i < q; ++i) {
cin >> a.at(i);
}
// cout << n << ',' << k << ',' << q << endl;
vector<int> score(n, k - q);
for (unsigned int i = 0; i < q; ++i) {
score.at(a.at(i) - 1)++;
}
for (unsigned int i = 0; i < n; ++i) {
// cout << "i: " << i << ", score[" << i << "]: " << score.at(i) << endl;
if (score.at(i) <= 0) {
cout << "No" << endl;
} else {
cout << "Yes" << endl;
}
}
}
| replace | 18 | 19 | 18 | 19 | 0 | |
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
int main() {
int n, k, q;
cin >> n >> k >> q;
vector<int> a(q);
rep(i, q) cin >> a[i];
vector<int> ans(n);
rep(i, n) ans[i] = k - q;
rep(i, n) { ans[a[i] - 1]++; }
rep(i, n) {
if (ans[i] > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
int main() {
int n, k, q;
cin >> n >> k >> q;
vector<int> a(q);
rep(i, q) cin >> a[i];
vector<int> ans(n);
rep(i, n) ans[i] = k - q;
rep(i, q) { ans[a[i] - 1]++; }
rep(i, n) {
if (ans[i] > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
| replace | 16 | 17 | 16 | 17 | -6 | double free or corruption (out)
|
p02911 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define vl vector<ll>
int main() {
ll n, k, q;
cin >> n >> k >> q;
vl a(n);
rep(i, n) cin >> a.at(i);
vl p(n);
vector<string> ans(n);
rep(i, q) p.at(a.at(i) - 1)++;
rep(i, n) {
if (k - q + p.at(i) > 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
} | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define vl vector<ll>
int main() {
ll n, k, q;
cin >> n >> k >> q;
vl a(q);
rep(i, q) cin >> a.at(i);
vl p(n);
vector<string> ans(n);
rep(i, q) p.at(a.at(i) - 1)++;
rep(i, n) {
if (k - q + p.at(i) > 0) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
} | replace | 9 | 11 | 9 | 11 | 0 | |
p02911 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
int main() {
int N, K, Q, p[10000] = {};
cin >> N >> K >> Q;
REP(i, Q) {
int A;
cin >> A;
p[A - 1]++;
}
REP(i, N) {
if (K - Q + p[i] > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
} | #include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
int main() {
int N, K, Q, p[100000] = {};
cin >> N >> K >> Q;
REP(i, Q) {
int A;
cin >> A;
p[A - 1]++;
}
REP(i, N) {
if (K - Q + p[i] > 0)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
} | replace | 19 | 20 | 19 | 20 | 0 | |
p02912 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define LOG(variable) cout << #variable ":\t" << (variable) << endl
#define LOGCON(i, container) \
for (int(i) = 0; (i) < (container).size(); ++(i)) \
cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for (int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) \
for (auto itr = (obj).begin(); itr != (obj).end(); ++itr)
#define REPROBJ(itr, obj) \
for (auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((x += MOD - a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime MOD
mint inv() const { return pow(MOD - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
int in() {
int x;
cin >> x;
return x;
}
string stin() {
string s;
cin >> s;
return s;
}
/***** MAIN *****/
signed main() {
int n, m;
cin >> n >> m;
vector<int> price(n);
REP(i, n) { cin >> price[i]; }
while (m > 0) {
SORTR(price);
price[0] /= 2;
--m;
}
int ans = 0;
for (auto &itr : price) {
ans += itr;
}
cout << ans;
cout << "\n";
return 0;
}
/***** MAIN *****/
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define LOG(variable) cout << #variable ":\t" << (variable) << endl
#define LOGCON(i, container) \
for (int(i) = 0; (i) < (container).size(); ++(i)) \
cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for (int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for (int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) \
for (auto itr = (obj).begin(); itr != (obj).end(); ++itr)
#define REPROBJ(itr, obj) \
for (auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((x += MOD - a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint a) const { return mint(*this) += a; }
mint operator-(const mint a) const { return mint(*this) -= a; }
mint operator*(const mint a) const { return mint(*this) *= a; }
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime MOD
mint inv() const { return pow(MOD - 2); }
mint &operator/=(const mint a) { return *this *= a.inv(); }
mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
int in() {
int x;
cin >> x;
return x;
}
string stin() {
string s;
cin >> s;
return s;
}
/***** MAIN *****/
signed main() {
int n, m;
cin >> n >> m;
vector<int> price(n);
REP(i, n) { cin >> price[i]; }
while (m > 0) {
SORTR(price);
int i = 0;
int max_n = price[0] / 2;
while (max_n <= price[i]) {
price[i] /= 2;
max_n = max(max_n, price[i]);
--m;
++i;
if (i >= n || m <= 0)
break;
}
}
int ans = 0;
for (auto &itr : price) {
ans += itr;
}
cout << ans;
cout << "\n";
return 0;
}
/***** MAIN *****/
| replace | 82 | 84 | 82 | 92 | TLE | |
p02912 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, M, T;
T = 0;
cin >> N >> M;
vector<long long> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
sort(A.begin(), A.end());
for (long long i = 0; i < M; i++) {
if (N > 10) {
if (A[N - 2] * 2 <= A[N - 1] && i < M && A[N - 1] > 0) {
while (A[N - 2] * 2 > A[N - 1] && i < M && A[N - 1] > 0) {
A[N - 1] /= 2;
i++;
}
// cout << "a";
}
while (A[0] * 2 >= A[N - 1] && i + N < M && A[N - 1] > 0) {
for (int i2 = N - 1; i2 >= 0; i2--) {
A[i2] /= 2;
i++;
// cout << "b";
// cout << i;
}
}
if (A[0] * 2 >= A[N - 1] && i + N >= M && A[N - 1] > 0) {
long long i3 = N - 1 - (M - i) + 1;
for (int i2 = N - 1; i2 >= i3; i2--) {
A[i2] /= 2;
i++;
// cout << "c";
}
} else if (A[N - 1] > 0) {
long long B = A[N - 1] / 2;
int i3 = N - 1;
while (A[i3] >= B && i < M && A[N - 1] > 0) {
A[i3] /= 2;
i3--;
i++;
// cout << "d";
}
}
} else {
A[N - 1] /= 2;
i++;
}
sort(A.begin(), A.end());
if (A[N - 1] == 0) {
i = M;
}
// cout << "WWO";
i--;
}
for (int i = 0; i < N; i++) {
T += A[i];
}
cout << T << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, M, T;
T = 0;
cin >> N >> M;
vector<long long> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
sort(A.begin(), A.end());
for (long long i = 0; i < M; i++) {
if (N > 10) {
if (A[N - 2] * 2 <= A[N - 1] && i < M && A[N - 1] > 0) {
while (A[N - 2] * 2 > A[N - 1] && i < M && A[N - 1] > 0) {
A[N - 1] /= 2;
i++;
}
// cout << "a";
}
while (A[0] * 2 >= A[N - 1] && i + N < M && A[N - 1] > 0) {
for (int i2 = N - 1; i2 >= 0; i2--) {
A[i2] /= 2;
i++;
// cout << "b";
// cout << i;
}
}
if (A[0] * 2 >= A[N - 1] && i + N >= M && A[N - 1] > 0) {
long long i3 = N - 1 - (M - i) + 1;
for (int i2 = N - 1; i2 >= i3; i2--) {
A[i2] /= 2;
i++;
// cout << "c";
}
} else if (A[N - 1] > 0) {
long long B = A[N - 1] / 2;
int i3 = N - 1;
while (A[i3] >= B && i < M && A[N - 1] > 0 && i3 >= 0) {
A[i3] /= 2;
i3--;
i++;
// cout << "d";
}
}
} else {
A[N - 1] /= 2;
i++;
}
sort(A.begin(), A.end());
if (A[N - 1] == 0) {
i = M;
}
// cout << "WWO";
i--;
}
for (int i = 0; i < N; i++) {
T += A[i];
}
cout << T << endl;
}
| replace | 39 | 40 | 39 | 40 | 0 | |
p02912 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define FOR(var, from, to) for (int var = (from); var <= (to); ++var)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define rep1(var, n) for (int var = 1; var <= (n); ++var)
#define repC2(vari, varj, n) \
for (int vari = 0; vari < (n)-1; ++vari) \
for (int varj = vari + 1; varj < (n); ++varj)
#define repC3(vari, varj, vark, n) \
for (int vari = 0; vari < (n)-2; ++vari) \
for (int varj = vari + 1; varj < (n)-1; ++varj) \
for (int vark = varj + 1; vark < (n); ++vark)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define tr(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define mset(arr, val) memset(arr, val, sizeof(arr))
#define mid(x, y) ((x) + ((y) - (x)) / 2)
#define IN(x, a, b) ((a) <= (x) && (x) <= (b))
using namespace std;
template <typename T> void Out(T x) { cout << x << endl; }
template <typename T1, typename T2> void Ans(bool f, T1 y, T2 n) {
if (f)
Out(y);
else
Out(n);
}
int main() {
int B, C, D, N, M, max;
ll ans;
cin >> N >> M;
vector<ll> A(N);
rep(i, N) { cin >> A[i]; }
if (N == 1) {
rep(i, M) {
if (A[0] <= 1) {
Out("0");
return 0;
}
A[0] /= 2;
}
Out(A[0]);
return 0;
}
for (int j = 0; 0 < M; j++) {
sort(RALL(A));
max = A[0];
for (int i = 0; i < N, 0 < M; i++) {
if (A[i] < (max / 2))
break;
A[i] /= 2;
M--;
}
}
ans = 0;
rep(i, N) { ans += A[i]; }
Out(ans);
return 0;
} | #include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define FOR(var, from, to) for (int var = (from); var <= (to); ++var)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define rep1(var, n) for (int var = 1; var <= (n); ++var)
#define repC2(vari, varj, n) \
for (int vari = 0; vari < (n)-1; ++vari) \
for (int varj = vari + 1; varj < (n); ++varj)
#define repC3(vari, varj, vark, n) \
for (int vari = 0; vari < (n)-2; ++vari) \
for (int varj = vari + 1; varj < (n)-1; ++varj) \
for (int vark = varj + 1; vark < (n); ++vark)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define tr(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define mset(arr, val) memset(arr, val, sizeof(arr))
#define mid(x, y) ((x) + ((y) - (x)) / 2)
#define IN(x, a, b) ((a) <= (x) && (x) <= (b))
using namespace std;
template <typename T> void Out(T x) { cout << x << endl; }
template <typename T1, typename T2> void Ans(bool f, T1 y, T2 n) {
if (f)
Out(y);
else
Out(n);
}
int main() {
int B, C, D, N, M, max;
ll ans;
cin >> N >> M;
vector<ll> A(N);
rep(i, N) { cin >> A[i]; }
if (N == 1) {
rep(i, M) {
if (A[0] <= 1) {
Out("0");
return 0;
}
A[0] /= 2;
}
Out(A[0]);
return 0;
}
for (int j = 0; 0 < M; j++) {
sort(RALL(A));
max = A[0];
for (int i = 0; (i < N && 0 < M); i++) {
if (A[i] < (max / 2))
break;
A[i] /= 2;
M--;
}
}
ans = 0;
rep(i, N) { ans += A[i]; }
Out(ans);
return 0;
} | replace | 55 | 56 | 55 | 56 | 0 | |
p02912 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
vector<int>::iterator itr;
size_t index;
while (m-- != 0) {
itr = max_element(a.begin(), a.end());
index = distance(a.begin(), itr);
a[index] /= 2;
}
long long ans = 0;
for (int i = 0; i < n; i++) {
ans += a[i];
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
for (int i = 0; m; i++) {
if (i == n)
i = 0;
if (a[0] > a[i]) {
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
i = -1;
continue;
}
a[i] /= 2;
m--;
}
long long ans = 0;
for (int i = 0; i < n; i++) {
ans += a[i];
}
cout << ans << endl;
return 0;
} | replace | 11 | 17 | 11 | 24 | TLE | |
p02912 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define int long long
int N, M;
vector<int> V(10);
int ans;
signed main() {
cin >> N >> M;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
ans += a;
int tmp = 1;
for (int j = 0; j < 50; j++) {
V.push_back(a / tmp - a / (tmp * 2));
tmp *= 2;
}
}
sort(V.rbegin(), V.rend());
for (int i = 0; i < M; i++)
ans -= V[i];
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long
int N, M;
vector<int> V(10);
int ans;
signed main() {
cin >> N >> M;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
ans += a;
int tmp = 1;
for (int j = 0; j < 50; j++) {
V.push_back(a / tmp - a / (tmp * 2));
tmp *= 2;
}
}
sort(V.rbegin(), V.rend());
for (int i = 0; i < min(M, (int)V.size()); i++)
ans -= V[i];
cout << ans << endl;
return 0;
} | replace | 23 | 24 | 23 | 24 | 0 | |
p02912 | 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 = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define itr(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define All(x) (x).begin(), (x).end()
#define rAll(x) (x).rbegin(), (x).rend()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1000000007;
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x * y / gcd(x, y); }
int roundup(int a, int b) { return (a - 1) / b + 1; }
void YN(bool flg) { cout << (flg ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << (flg ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << (flg ? "yes" : "no") << endl; }
struct rational {
long long p, q;
long long gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
void normalize() { // keep q positive
if (q < 0)
p *= -1, q *= -1;
long long d = gcd(p < 0 ? -p : p, q);
if (d == 0)
p = 0, q = 1;
else
p /= d, q /= d;
}
rational(long long p, long long q = 1) : p(p), q(q) { normalize(); }
rational &operator+=(const rational &a) {
p = a.q * p + a.p * q;
q = a.q * q;
normalize();
return *this;
}
rational &operator-=(const rational &a) {
p = a.q * p - a.p * q;
q = a.q * q;
normalize();
return *this;
}
rational &operator*=(const rational &a) {
p *= a.p;
q *= a.q;
normalize();
return *this;
}
rational &operator/=(const rational &a) {
p *= a.q;
q *= a.p;
normalize();
return *this;
}
rational &operator-() {
p *= -1;
return *this;
}
friend rational operator+(const rational &a, const rational &b) {
return rational(a) += b;
}
friend rational operator*(const rational &a, const rational &b) {
return rational(a) *= b;
}
friend rational operator-(const rational &a, const rational &b) {
return rational(a) -= b;
}
friend rational operator/(const rational &a, const rational &b) {
return rational(a) /= b;
}
friend bool operator<(const rational &a,
const rational &b) { // avoid overflow
return (long double)a.p * b.q < (long double)a.q * b.p;
}
friend bool operator<=(const rational &a, const rational &b) {
return !(b < a);
}
friend bool operator>(const rational &a, const rational &b) { return b < a; }
friend bool operator>=(const rational &a, const rational &b) {
return !(a < b);
}
friend bool operator==(const rational &a, const rational &b) {
return !(a < b) && !(b < a);
}
friend bool operator!=(const rational &a, const rational &b) {
return (a < b) || (b < a);
}
friend std::ostream &operator<<(std::ostream &os, const rational &x) {
printf("%.16f", (double)x.p / (double)x.q);
return os;
}
friend std::istream &operator>>(std::istream &is, rational &x) {
is >> x.p >> x.q;
x.normalize();
return is;
}
};
signed main() {
int n, m;
cin >> n >> m;
multiset<rational, greater<rational>> ms;
rep(i, n) {
int a;
cin >> a;
ms.insert(rational(a, 1));
}
rep(i, m) {
rational tar = *ms.begin();
ms.erase(ms.begin());
tar /= rational(2, 1);
ms.insert(tar);
}
int ans = 0;
for (auto c : ms)
ans += c.p / c.q;
cout << ans << 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 = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define itr(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define All(x) (x).begin(), (x).end()
#define rAll(x) (x).rbegin(), (x).rend()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int mod = 1000000007;
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x * y / gcd(x, y); }
int roundup(int a, int b) { return (a - 1) / b + 1; }
void YN(bool flg) { cout << (flg ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << (flg ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << (flg ? "yes" : "no") << endl; }
struct rational {
long long p, q;
long long gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
void normalize() { // keep q positive
if (q < 0)
p *= -1, q *= -1;
long long d = gcd(p < 0 ? -p : p, q);
if (d == 0)
p = 0, q = 1;
else
p /= d, q /= d;
}
rational(long long p, long long q = 1) : p(p), q(q) { normalize(); }
rational &operator+=(const rational &a) {
p = a.q * p + a.p * q;
q = a.q * q;
normalize();
return *this;
}
rational &operator-=(const rational &a) {
p = a.q * p - a.p * q;
q = a.q * q;
normalize();
return *this;
}
rational &operator*=(const rational &a) {
p *= a.p;
q *= a.q;
normalize();
return *this;
}
rational &operator/=(const rational &a) {
p *= a.q;
q *= a.p;
normalize();
return *this;
}
rational &operator-() {
p *= -1;
return *this;
}
friend rational operator+(const rational &a, const rational &b) {
return rational(a) += b;
}
friend rational operator*(const rational &a, const rational &b) {
return rational(a) *= b;
}
friend rational operator-(const rational &a, const rational &b) {
return rational(a) -= b;
}
friend rational operator/(const rational &a, const rational &b) {
return rational(a) /= b;
}
friend bool operator<(const rational &a,
const rational &b) { // avoid overflow
return (long double)a.p * b.q < (long double)a.q * b.p;
}
friend bool operator<=(const rational &a, const rational &b) {
return !(b < a);
}
friend bool operator>(const rational &a, const rational &b) { return b < a; }
friend bool operator>=(const rational &a, const rational &b) {
return !(a < b);
}
friend bool operator==(const rational &a, const rational &b) {
return !(a < b) && !(b < a);
}
friend bool operator!=(const rational &a, const rational &b) {
return (a < b) || (b < a);
}
friend std::ostream &operator<<(std::ostream &os, const rational &x) {
printf("%.16f", (double)x.p / (double)x.q);
return os;
}
friend std::istream &operator>>(std::istream &is, rational &x) {
is >> x.p >> x.q;
x.normalize();
return is;
}
};
signed main() {
int n, m;
cin >> n >> m;
multiset<rational, greater<rational>> ms;
rep(i, n) {
int a;
cin >> a;
ms.insert(rational(a, 1));
}
rep(i, m) {
rational tar = *ms.begin();
ms.erase(ms.begin());
if (tar.p / tar.q < 1)
break;
tar /= rational(2, 1);
ms.insert(tar);
}
int ans = 0;
for (auto c : ms)
ans += c.p / c.q;
cout << ans << endl;
}
| insert | 113 | 113 | 113 | 115 | 0 | |
p02912 | C++ | Time Limit Exceeded | #include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
priority_queue<int> que;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
que.push(a);
}
while (M > 0) {
int t = que.top();
que.pop();
M--;
t /= 2;
if (t > 0)
que.push(t);
}
long long res = 0;
while (!que.empty()) {
int t = que.top();
que.pop();
res += t;
}
cout << res << endl;
return 0;
} | #include <iostream>
#include <queue>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
priority_queue<int> que;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
que.push(a);
}
while (M > 0 && !que.empty()) {
int t = que.top();
que.pop();
M--;
t /= 2;
if (t > 0)
que.push(t);
}
long long res = 0;
while (!que.empty()) {
int t = que.top();
que.pop();
res += t;
}
cout << res << endl;
return 0;
} | replace | 15 | 16 | 15 | 16 | TLE | |
p02912 | C++ | Time Limit Exceeded | /*{{{*/
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) \
(sort(c.begin(), c.end()), \
c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin())
#define CASET \
int ___T; \
scanf("%d", &___T); \
for (int cs = 1; cs <= ___T; cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
template <class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U> void R(T &head, U &...tail) {
_R(head);
R(tail...);
}
template <class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U> void _W(const pair<T, U> &x) {
_W(x.F);
putchar(' ');
_W(x.S);
}
template <class T> void _W(const vector<T> &x) {
for (auto i = x.begin(); i != x.end(); _W(*i++))
if (i != x.cbegin())
putchar(' ');
}
void W() {}
template <class T, class... U> void W(const T &head, const U &...tail) {
_W(head);
putchar(sizeof...(tail) ? ' ' : '\n');
W(tail...);
}
#ifdef HOME
#define DEBUG(...) \
{ \
printf("# "); \
printf(__VA_ARGS__); \
puts(""); \
}
#else
#define DEBUG(...)
#endif
int MOD = 1e9 + 7;
void ADD(LL &x, LL v) {
x = (x + v) % MOD;
if (x < 0)
x += MOD;
}
/*}}}*/
const int SIZE = 1e6 + 10;
int main() {
priority_queue<int> AA;
int N, M;
R(N, M);
FOR(i, 1, N) {
int x;
R(x);
AA.push(x);
}
REP(i, M) {
int v = AA.top();
AA.pop();
if (v > 1)
AA.push(v / 2);
}
LL an = 0;
while (!AA.empty()) {
an += AA.top();
AA.pop();
}
W(an);
return 0;
}
| /*{{{*/
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) \
(sort(c.begin(), c.end()), \
c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define GET_POS(c, x) (lower_bound(c.begin(), c.end(), x) - c.begin())
#define CASET \
int ___T; \
scanf("%d", &___T); \
for (int cs = 1; cs <= ___T; cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
template <class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U> void R(T &head, U &...tail) {
_R(head);
R(tail...);
}
template <class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T, class U> void _W(const pair<T, U> &x) {
_W(x.F);
putchar(' ');
_W(x.S);
}
template <class T> void _W(const vector<T> &x) {
for (auto i = x.begin(); i != x.end(); _W(*i++))
if (i != x.cbegin())
putchar(' ');
}
void W() {}
template <class T, class... U> void W(const T &head, const U &...tail) {
_W(head);
putchar(sizeof...(tail) ? ' ' : '\n');
W(tail...);
}
#ifdef HOME
#define DEBUG(...) \
{ \
printf("# "); \
printf(__VA_ARGS__); \
puts(""); \
}
#else
#define DEBUG(...)
#endif
int MOD = 1e9 + 7;
void ADD(LL &x, LL v) {
x = (x + v) % MOD;
if (x < 0)
x += MOD;
}
/*}}}*/
const int SIZE = 1e6 + 10;
int main() {
priority_queue<int> AA;
int N, M;
R(N, M);
FOR(i, 1, N) {
int x;
R(x);
AA.push(x);
}
REP(i, M) {
if (SZ(AA) == 0)
break;
int v = AA.top();
AA.pop();
if (v > 1)
AA.push(v / 2);
}
LL an = 0;
while (!AA.empty()) {
an += AA.top();
AA.pop();
}
W(an);
return 0;
}
| insert | 109 | 109 | 109 | 111 | TLE | |
p02912 | C++ | Time Limit Exceeded | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
priority_queue<int> p;
for (int i = 0; i < n; i++) {
int tmp;
cin >> tmp;
p.push(tmp);
}
for (int i = 0; i < m; i++) {
int tmp = p.top();
p.pop();
p.push(tmp / 2);
}
long long int ans = 0;
while (!p.empty()) {
ans += p.top();
p.pop();
}
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
priority_queue<int> p;
for (int i = 0; i < n; i++) {
int tmp;
cin >> tmp;
p.push(tmp);
}
for (int i = 0; i < m; i++) {
int tmp = p.top();
p.pop();
p.push(tmp / 2);
}
long long int ans = 0;
while (!p.empty()) {
ans += p.top();
p.pop();
}
cout << ans;
return 0;
} | delete | 0 | 1 | 0 | 0 | TLE | |
p02912 | Python | Runtime Error | import heapq
n, m = map(int, input().split())
a = map(int, input().split())
a = map(lambda x: -x, a)
heapq.heapify(a)
for i in range(m):
tmp = -heapq.heappop(a) // 2
heapq.heappush(a, -tmp)
print(-sum(a))
| import heapq
n, m = map(int, input().split())
a = map(int, input().split())
a = list(map(lambda x: -x, a))
heapq.heapify(a)
for i in range(m):
tmp = -heapq.heappop(a) // 2
heapq.heappush(a, -tmp)
print(-sum(a))
| replace | 4 | 5 | 4 | 5 | TypeError: heapify() argument must be list, not map | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02912/Python/s087628068.py", line 6, in <module>
heapq.heapify(a)
TypeError: heapify() argument must be list, not map
|
p02912 | C++ | Runtime Error | #include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
typedef long long ll;
typedef pair<int, pair<int, int>> P;
typedef vector<int> V;
typedef map<int, int> M;
constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m, a[112345];
int b[11234][31];
memset(b, 0, sizeof(b));
ll sum = 0;
cin >> n >> m;
REP(i, n) {
cin >> a[i];
sum += a[i];
ll j = 0;
while (true) {
b[i][j] = a[i] / (1LL << j);
if (a[i] / (1LL << j) == 0)
break;
j++;
}
}
priority_queue<P> q;
REP(i, n) { q.push({b[i][0] - b[i][1], {i, 1}}); }
while (m) {
P p = q.top();
q.pop();
sum -= p.first;
m--;
q.push({b[p.second.first][p.second.second] -
b[p.second.first][p.second.second + 1],
{p.second.first, p.second.second + 1}});
}
cout << sum << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
typedef long long ll;
typedef pair<int, pair<int, int>> P;
typedef vector<int> V;
typedef map<int, int> M;
constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m, a[112345];
int b[112345][31];
memset(b, 0, sizeof(b));
ll sum = 0;
cin >> n >> m;
REP(i, n) {
cin >> a[i];
sum += a[i];
ll j = 0;
while (true) {
b[i][j] = a[i] / (1LL << j);
if (a[i] / (1LL << j) == 0)
break;
j++;
}
}
priority_queue<P> q;
REP(i, n) { q.push({b[i][0] - b[i][1], {i, 1}}); }
while (m) {
P p = q.top();
q.pop();
sum -= p.first;
m--;
q.push({b[p.second.first][p.second.second] -
b[p.second.first][p.second.second + 1],
{p.second.first, p.second.second + 1}});
}
cout << sum << endl;
return 0;
} | replace | 38 | 39 | 38 | 39 | 0 | |
p02912 | C++ | Runtime Error | #include <algorithm>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
long N, M;
scanf("%ld", &N);
scanf("%ld", &M);
std::priority_queue<long> que;
for (long i = 0; i < N; i++) {
long tmp;
scanf("%ld", tmp);
que.push(tmp);
}
long tmp;
for (long i = 0; i < M; i++) {
tmp = que.top();
que.pop();
que.push(tmp / 2);
}
long long ans = 0;
for (long i = 0; i < N; i++) {
ans += que.top();
que.pop();
}
printf("%ld\n", ans);
return 0;
} | #include <algorithm>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
long N, M;
scanf("%ld", &N);
scanf("%ld", &M);
std::priority_queue<long> que;
for (long i = 0; i < N; i++) {
long tmp;
scanf("%ld", &tmp);
que.push(tmp);
}
long tmp;
for (long i = 0; i < M; i++) {
tmp = que.top();
que.pop();
que.push(tmp / 2);
}
long long ans = 0;
for (long i = 0; i < N; i++) {
ans += que.top();
que.pop();
}
printf("%ld\n", ans);
return 0;
} | replace | 13 | 14 | 13 | 14 | -11 | |
p02912 | C++ | Time Limit Exceeded | #define _GLIBCXX_DEBUG
#include <algorithm> //next_permutation
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
const ll MOD = 1000000007;
const ll MAX = 2000001;
ll mod(ll a) { return a % MOD; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll fac[MAX], finv[MAX], inv[MAX];
void nCrprep() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (ll 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;
}
}
ll nCr(ll n, ll r) {
if (n < r)
return 0;
if (n < 0 || r < 0)
return 0;
return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
ll nCrcheep(ll n, ll r) {
if (r == 0)
return 1;
else if (r == 1)
return n;
else
return nCrcheep(n - 1, r - 1) * n / r;
}
vector<pair<ll, ll>> prime_factorize(ll n) {
vector<pair<ll, ll>> res;
for (ll i = 2; i * i <= n; i++) {
if (n % i != 0)
continue;
ll ex = 0;
while (n % i == 0) {
ex++;
n /= i;
}
res.push_back({i, ex});
}
if (n != 1)
res.push_back({n, 1});
return res;
}
int main() {
ll n, m;
cin >> n >> m;
ll ans = 0;
priority_queue<ll> pq;
ll x = 0;
rep(i, n) {
cin >> x;
pq.push(x);
}
rep(i, m) {
x = pq.top();
pq.pop();
pq.push(x / 2);
}
rep(i, n) {
ans += pq.top();
pq.pop();
}
cout << ans << endl;
} | #include <algorithm> //next_permutation
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vl>;
ll gcd(ll a, ll b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
const ll MOD = 1000000007;
const ll MAX = 2000001;
ll mod(ll a) { return a % MOD; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll fac[MAX], finv[MAX], inv[MAX];
void nCrprep() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (ll 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;
}
}
ll nCr(ll n, ll r) {
if (n < r)
return 0;
if (n < 0 || r < 0)
return 0;
return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
ll nCrcheep(ll n, ll r) {
if (r == 0)
return 1;
else if (r == 1)
return n;
else
return nCrcheep(n - 1, r - 1) * n / r;
}
vector<pair<ll, ll>> prime_factorize(ll n) {
vector<pair<ll, ll>> res;
for (ll i = 2; i * i <= n; i++) {
if (n % i != 0)
continue;
ll ex = 0;
while (n % i == 0) {
ex++;
n /= i;
}
res.push_back({i, ex});
}
if (n != 1)
res.push_back({n, 1});
return res;
}
int main() {
ll n, m;
cin >> n >> m;
ll ans = 0;
priority_queue<ll> pq;
ll x = 0;
rep(i, n) {
cin >> x;
pq.push(x);
}
rep(i, m) {
x = pq.top();
pq.pop();
pq.push(x / 2);
}
rep(i, n) {
ans += pq.top();
pq.pop();
}
cout << ans << endl;
}
| delete | 0 | 1 | 0 | 0 | TLE | |
p02912 | C++ | Runtime Error | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) \
for (int iii = 0; iii < v.size(); iii++) { \
cout << v[iii] << " "; \
} \
cout << endl;
#define show(iiii) cout << iiii << endl;
#define shows(iiiii) cout << iiiii << " ";
#define divs 1000000007
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stdio.h>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
multiset<int> a;
unsigned long long int sum = 0;
rep(i, n) {
int buf;
cin >> buf;
a.insert(buf);
sum += buf;
}
unsigned long long int sakugen = 0;
rep(i, m) {
auto itr = a.end();
int targ = *itr;
sakugen += (targ - targ / 2);
a.erase(itr);
a.insert(targ / 2);
}
cout << sum - sakugen;
}
| #define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) \
for (int iii = 0; iii < v.size(); iii++) { \
cout << v[iii] << " "; \
} \
cout << endl;
#define show(iiii) cout << iiii << endl;
#define shows(iiiii) cout << iiiii << " ";
#define divs 1000000007
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stdio.h>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
multiset<int> a;
unsigned long long int sum = 0;
rep(i, n) {
int buf;
cin >> buf;
a.insert(buf);
sum += buf;
}
unsigned long long int sakugen = 0;
rep(i, m) {
auto itr = a.end();
itr--;
int targ = *itr;
sakugen += (targ - targ / 2);
a.erase(itr);
a.insert(targ / 2);
}
cout << sum - sakugen;
}
| insert | 42 | 42 | 42 | 43 | -6 | free(): invalid pointer
|
p02912 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
// Compiler version g++ 6.3.0
int main() {
ll n, m, ans = 0;
cin >> n >> m;
vector<ll> x;
for (int i = 0; i < n; i++) {
ll a;
cin >> a;
ans += a;
while (a != 1) {
x.push_back(a - a / 2);
a = a / 2;
}
x.push_back(1);
}
sort(x.begin(), x.end());
ll y = x.size();
for (int i = 0; i < m; i++) {
ans -= x.at(y - i - 1);
}
cout << ans << endl;
} | #include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
// Compiler version g++ 6.3.0
int main() {
ll n, m, ans = 0;
cin >> n >> m;
vector<ll> x;
for (int i = 0; i < n; i++) {
ll a;
cin >> a;
ans += a;
while (a != 1) {
x.push_back(a - a / 2);
a = a / 2;
}
x.push_back(1);
}
sort(x.begin(), x.end());
ll y = x.size();
if (x.size() <= m) {
cout << 0 << endl;
return 0;
}
for (int i = 0; i < m; i++) {
ans -= x.at(y - i - 1);
}
cout << ans << endl;
} | insert | 22 | 22 | 22 | 26 | 0 | |
p02912 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
for (auto &v : vec)
is >> v;
return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
os << "[";
for (auto v : vec)
os << v << ", ";
os << "]";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) {
os << "deq[";
for (auto v : vec)
os << v << ", ";
os << "]";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) {
os << "{";
for (auto v : vec)
os << v << ", ";
os << "}";
return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &vec) {
os << "{";
for (auto v : vec)
os << v << ", ";
os << "}";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) {
os << "{";
for (auto v : vec)
os << v << ", ";
os << "}";
return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) {
os << "{";
for (auto v : vec)
os << v << ", ";
os << "}";
return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa) {
os << "(" << pa.first << ", " << pa.second << ")";
return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp) {
os << "{";
for (auto v : mp)
os << v.first << ": " << v.second << ", ";
os << "}";
return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp) {
os << "{";
for (auto v : mp)
os << v.first << ": " << v.second << ", ";
os << "}";
return os;
}
template <typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template <typename T, typename... Args>
void ndarray(vector<T> &vec, int len, Args... args) {
vec.resize(len);
for (auto &v : vec)
ndarray(v, args...);
}
template <typename T> bool chmax(T &m, const T q) {
if (m < q) {
m = q;
return true;
} else
return false;
}
template <typename T> bool chmin(T &m, const T q) {
if (q < m) {
m = q;
return true;
} else
return false;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) {
return make_pair(l.first + r.first, l.second + r.second);
}
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) {
return make_pair(l.first - r.first, l.second - r.second);
}
#define f first
#define s second
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int len, tickets;
cin >> len >> tickets;
vector<int> arr(len);
long long ans = 0;
for (int i = 0; i < len; i++) {
cin >> arr[i];
ans += arr[i];
}
while (tickets > 0) {
sort(arr.begin(), arr.end());
int target = arr[len - 1] / 2;
int i = len - 1;
while (i >= 0 && arr[i] > target) {
ans -= arr[i] - arr[i] / 2;
arr[i] = arr[i] / 2;
i--;
tickets--;
if (tickets == 0)
break;
}
}
cout << ans;
} | #include <bits/stdc++.h>
using namespace std;
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
for (auto &v : vec)
is >> v;
return is;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
os << "[";
for (auto v : vec)
os << v << ", ";
os << "]";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) {
os << "deq[";
for (auto v : vec)
os << v << ", ";
os << "]";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) {
os << "{";
for (auto v : vec)
os << v << ", ";
os << "}";
return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &vec) {
os << "{";
for (auto v : vec)
os << v << ", ";
os << "}";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) {
os << "{";
for (auto v : vec)
os << v << ", ";
os << "}";
return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) {
os << "{";
for (auto v : vec)
os << v << ", ";
os << "}";
return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa) {
os << "(" << pa.first << ", " << pa.second << ")";
return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp) {
os << "{";
for (auto v : mp)
os << v.first << ": " << v.second << ", ";
os << "}";
return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp) {
os << "{";
for (auto v : mp)
os << v.first << ": " << v.second << ", ";
os << "}";
return os;
}
template <typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template <typename T, typename... Args>
void ndarray(vector<T> &vec, int len, Args... args) {
vec.resize(len);
for (auto &v : vec)
ndarray(v, args...);
}
template <typename T> bool chmax(T &m, const T q) {
if (m < q) {
m = q;
return true;
} else
return false;
}
template <typename T> bool chmin(T &m, const T q) {
if (q < m) {
m = q;
return true;
} else
return false;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) {
return make_pair(l.first + r.first, l.second + r.second);
}
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) {
return make_pair(l.first - r.first, l.second - r.second);
}
#define f first
#define s second
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int len, tickets;
cin >> len >> tickets;
vector<int> arr(len);
long long ans = 0;
for (int i = 0; i < len; i++) {
cin >> arr[i];
ans += arr[i];
}
if (len == 1) {
cout << (int)(arr[0] / pow(2, tickets));
return 0;
}
while (tickets > 0) {
sort(arr.begin(), arr.end());
int target = arr[len - 1] / 2;
int i = len - 1;
while (i >= 0 && arr[i] > target) {
ans -= arr[i] - arr[i] / 2;
arr[i] = arr[i] / 2;
i--;
tickets--;
if (tickets == 0)
break;
}
}
cout << ans;
} | insert | 116 | 116 | 116 | 120 | TLE | |
p02912 | C++ | Runtime Error | #include <iostream>
#include <queue>
int main() {
int n, m;
std::cin >> n >> m;
std::priority_queue<long long> que;
int i;
for (i = 0; i < n; i++) {
long A;
std::cin >> A;
}
for (i = 0; i < m; i++) {
long long t = que.top();
que.pop();
que.push(t / 2);
}
long long res = 0;
while (!que.empty()) {
res += que.top();
que.pop();
}
std::cout << res;
} | #include <iostream>
#include <queue>
int main() {
int n, m;
std::cin >> n >> m;
std::priority_queue<long long> que;
int i;
for (i = 0; i < n; i++) {
long A;
std::cin >> A;
que.push(A);
}
for (i = 0; i < m; i++) {
long long t = que.top();
que.pop();
que.push(t / 2);
}
long long res = 0;
while (!que.empty()) {
res += que.top();
que.pop();
}
std::cout << res;
} | insert | 12 | 12 | 12 | 13 | -11 | |
p02912 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
long long ans;
inline int nextInt() {
int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = getchar();
}
return x * f;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
multiset<int> A;
while (N--) {
A.insert(nextInt());
}
while (M--) {
int a = *prev(A.end());
A.erase(prev(A.end()));
a /= 2;
A.insert(a);
}
for (auto &a : A) {
ans += a;
}
printf("%lld\n", ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
long long ans;
inline int nextInt() {
int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = getchar();
}
return x * f;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N, M;
cin >> N >> M;
multiset<int> A;
while (N--) {
int a;
cin >> a;
A.insert(a);
}
while (M--) {
int a = *prev(A.end());
A.erase(prev(A.end()));
a /= 2;
A.insert(a);
}
for (auto &a : A) {
ans += a;
}
printf("%lld\n", ans);
return 0;
}
| replace | 24 | 25 | 24 | 27 | TLE | |
p02912 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;
ll mod = 1e9 + 7ll;
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;
}
const ll inf = 1ll << 60;
int n, m;
vector<pair<int, int>> seg(210000);
int l = 0;
void kousin(int i, int k) {
// i番目の値をkに更新
int pointer = (1 << l) - 1 + i;
seg.at(pointer) = make_pair(k, i);
rp(salkj, 0, l) {
pointer = (pointer + 1) / 2 - 1;
seg.at(pointer) = max(seg.at(pointer * 2 + 1), seg.at(pointer * 2 + 2));
}
}
int main() {
cin >> n >> m;
// セグ木の大きさを決める
while (1 << l < n)
l++;
// 入力を受けてセグ木を構成
rp(i, 0, n) {
int a;
scanf("%d", &a);
kousin(i, a);
}
// m回、クエリを実行
// 今回の場合クエリは、全範囲の中で最大のものの値を半分にする
rp(i, 0, m) { kousin(seg.at(0).second, seg.at(0).first / 2); }
ll ans = 0;
rp(i, 0, n) { ans += seg.at((1 << l) - 1 + i).first; }
printf("%lld", ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;
ll mod = 1e9 + 7ll;
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;
}
const ll inf = 1ll << 60;
int n, m;
vector<pair<int, int>> seg(300000);
int l = 0;
void kousin(int i, int k) {
// i番目の値をkに更新
int pointer = (1 << l) - 1 + i;
seg.at(pointer) = make_pair(k, i);
rp(salkj, 0, l) {
pointer = (pointer + 1) / 2 - 1;
seg.at(pointer) = max(seg.at(pointer * 2 + 1), seg.at(pointer * 2 + 2));
}
}
int main() {
cin >> n >> m;
// セグ木の大きさを決める
while (1 << l < n)
l++;
// 入力を受けてセグ木を構成
rp(i, 0, n) {
int a;
scanf("%d", &a);
kousin(i, a);
}
// m回、クエリを実行
// 今回の場合クエリは、全範囲の中で最大のものの値を半分にする
rp(i, 0, m) { kousin(seg.at(0).second, seg.at(0).first / 2); }
ll ans = 0;
rp(i, 0, n) { ans += seg.at((1 << l) - 1 + i).first; }
printf("%lld", ans);
return 0;
}
| replace | 25 | 26 | 25 | 26 | 0 | |
p02912 | C++ | Time Limit Exceeded | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define int long long
signed main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
priority_queue<int> q;
rep(i, n) {
int a;
cin >> a;
q.push(a);
}
rep(i, m) {
int a = q.top();
q.pop();
q.push(a / 2);
}
int ans = 0;
rep(i, n) {
ans += q.top();
q.pop();
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define int long long
signed main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
priority_queue<int> q;
rep(i, n) {
int a;
cin >> a;
q.push(a);
}
rep(i, m) {
int a = q.top();
q.pop();
q.push(a / 2);
}
int ans = 0;
rep(i, n) {
ans += q.top();
q.pop();
}
cout << ans << endl;
return 0;
} | delete | 0 | 1 | 0 | 0 | TLE | |
p02912 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, j) for (long long i = 0; i < j; i++)
#define int long long
using namespace std;
signed main() {
int N, M, x;
cin >> N >> M;
vector<int> A_arr;
vector<int> A_subarr;
rep(i, N) {
cin >> x;
A_arr.push_back(x);
}
sort(A_arr.begin(), A_arr.end(), std::greater<int>());
while (M > 0) {
int A_0 = A_arr[0] / 2;
rep(i, N) {
int A_i = A_arr[i];
if (M > 0 && A_i > A_0) {
M--;
A_arr[i] = A_i / 2;
} else {
sort(A_arr.begin(), A_arr.end(), std::greater<int>());
break;
}
}
}
int answer = 0;
rep(i, N) { answer += A_arr[i]; }
cout << answer << endl;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, j) for (long long i = 0; i < j; i++)
#define int long long
using namespace std;
signed main() {
int N, M, x;
cin >> N >> M;
vector<int> A_arr;
vector<int> A_subarr;
rep(i, N) {
cin >> x;
A_arr.push_back(x);
}
sort(A_arr.begin(), A_arr.end(), std::greater<int>());
int pre_M = M + 1;
while (M > 0 && pre_M != M) {
pre_M = M;
int A_0 = A_arr[0] / 2;
rep(i, N) {
int A_i = A_arr[i];
if (M > 0 && A_i > A_0) {
M--;
A_arr[i] = A_i / 2;
} else {
sort(A_arr.begin(), A_arr.end(), std::greater<int>());
break;
}
}
}
int answer = 0;
rep(i, N) { answer += A_arr[i]; }
cout << answer << endl;
}
| replace | 20 | 21 | 20 | 23 | TLE | |
p02912 | C++ | Runtime Error | // Author : Abdallah Hemdan
/*Dear online judge:
* I've read the problem, and tried to solve it.
* Even if you don't accept my solution, you should respect my effort.
* I hope my code compiles and gets accepted.
* ___ __
* |\ \|\ \
* \ \ \_\ \
* \ \ ___ \emdan
* \ \ \\ \ \
* \ \__\\ \_\
* \|__| \|__|
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define MP make_pair
#define PB push_back
#define eb emplace_back
#define endl '\n'
#define xx first
#define yy second
#define sz size()
#define vi vector<int>
#define vll vector<ll>
#define ul unsigned long
#define vs vector<string>
#define si set<int>
#define sll set<ll>
#define IO \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define all(v) ((v).begin()), ((v).end())
#define rall(v) ((v).rbegin()), ((v).rend())
#define Ceil(x, y) ((x + y - 1) / y)
#define lop(i, b, e) \
for (ll i = (b) - ((b) > (e)); i != (e) - ((b) > (e)); \
i += 1 - 2 * ((b) > (e)))
#define lopi(i, init, n, incr) for (ll i = init; i < n; i += incr)
#define Even(Num) Num % 2 == 0
#define mms(Arr, Value) memset(Arr, Value, sizeof(Arr))
#define SetPre(Ans, num) fixed << setprecision(num) << (Ans)
#define clr clear()
#define re return
#define print(ans) cout << ans << endl
#define print2(a, b) cout << a << ' ' << b << endl
#define vpii vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pi acos(-1)
#define fix(a, k) (ll(a) % ll(k) + k) % k
#define in insert
#define sc(n) cin >> n
#define sc2(n, m) cin >> n >> m
#define sc3(a, b, c) cin >> a >> b >> c
#define sc4(a, b, c, d) cin >> a >> b >> c >> d
#define watch(x) cout << (#x) << " is " << (x) << endl
#define stringToLower(s) transform(all(s), s.begin(), ::tolower);
#define stringToUpper(s) transform(all(s), s.begin(), ::toupper);
#define noOfDigits(n) (1 + floor(log10(n)))
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)
#define modulo(S, N) ((S) & (N - 1)) // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) \
((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
#define posOfFirstSetBit(n) (log2(n & -n) + 1);
typedef long long int ll;
typedef long double ld;
typedef int8_t i8;
typedef uint8_t ui8;
typedef int16_t i16;
typedef uint16_t ui16;
typedef int32_t i32;
typedef uint32_t ui32;
typedef int64_t i64;
typedef uint64_t ui64;
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
return __builtin_popcount((ui32)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int oo = INT_MAX;
const ll OO = 1e18;
const int monthly[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int alldx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int alldy[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dx[] = {1, -1, 0, 0, 0, 0};
const int dy[] = {0, 0, 1, -1, 0, 0};
const int dz[] = {0, 0, 0, 0, 1, -1};
using namespace std;
string Letters = "0123456789ABCDEF";
int toInt(char c) { re Letters.find(c); }
ll FromAnyBaseToDecimal(string inp, int base) {
ll res = 0;
lop(i, 0, inp.sz) {
res *= base;
res += toInt(inp[i]);
}
re res;
}
string FromDecimalToAnyBase(ll n, int base) {
if (n == 0)
re "0";
string ans = "";
while (n) {
ans = Letters[n % base] + ans;
n /= base;
}
re ans;
}
ll GCD(ll a, ll b) { re((!b) ? a : GCD(b, a % b)); }
ll LCM(ll a, ll b) { re a / (GCD(a, b)) * b; }
ll nCr(ll n, ll r) {
if (n < r)
re 0;
if (r == 0)
re 1;
re n *nCr(n - 1, r - 1) / r;
}
ll PowMod(ll bs, ll ex, ll M) {
if (!ex)
re 1;
ll p = PowMod((bs * bs) % M, ex >> 1, M);
re(ex & 1) ? (p * bs) % M : p;
}
ll fastpow(ll b, ll e) {
if (!e)
re 1;
if (e & 1)
re b *fastpow(b, e - 1);
ll x = fastpow(b, e / 2);
re x *x;
}
ll ModInverse(ll a) { re PowMod(a, MOD - 2, MOD); }
ll ExtGCD(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1;
y = 0;
re a;
}
ll r = ExtGCD(b, a % b, y, x);
y -= a / b * x;
re r;
}
ll mult(ll a, ll b) { re(1LL * a * b) % MOD; }
ll SumOfOdd(ll l, ll r) {
ll Rsm = (r + 1) / 2;
Rsm *= Rsm;
l--;
ll Lsm = (l + 1) / 2;
Lsm *= Lsm;
re Rsm - Lsm;
}
ll NoOfOdd(ll L, ll R) {
ll N = (R - L) / 2;
if (R % 2 != 0 || L % 2 != 0)
N++;
re N;
}
ll NoOfEven(ll L, ll R) { re((R - L + 1) - NoOfOdd(L, R)); }
bool PointInRectangle(ll x1, ll y1, ll x2, ll y2, ll x, ll y) {
re(x >= x1 && x <= x2 && y >= y1 && y <= y2);
}
bool isPrime(ll n) {
if (n == 2)
re 1;
if (n < 2 || n % 2 == 0)
re 0;
for (ll i = 3; i * i <= n; i += 2)
if (n % i == 0)
re 0;
re 1;
}
bool isPalindrome(string str) {
ll l = 0;
ll h = str.sz - 1;
while (h > l) {
if (str[l++] != str[h--]) {
re 0;
}
}
re 1;
}
bool isPerfectSquare(ld x) {
ld sr = sqrt(x);
re((sr - floor(sr)) == 0);
}
bool isPerfectCube(ll n) {
ll curoot = round(pow(n, 1.0 / 3.0));
re(pow(curoot, 3) == n);
}
double distance(double x1, double y1, double x2, double y2) {
re hypot(fabs(x1 - x2), fabs(y1 - y2));
}
int main() {
#ifndef ONLINE_JUDGE
freopen("In.txt", "r", stdin);
// freopen("Out.txt", "w", stdout);
#else
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
IO;
ll n, k;
cin >> n >> k;
priority_queue<ll> pq;
lop(i, 0, n) {
ll x;
cin >> x;
pq.push(x);
}
while (k--) {
ll tp = pq.top();
pq.pop();
pq.push(tp >> 1);
}
ll sm = 0;
while (!pq.empty()) {
sm += pq.top();
pq.pop();
}
cout << sm << endl;
}
| // Author : Abdallah Hemdan
/*Dear online judge:
* I've read the problem, and tried to solve it.
* Even if you don't accept my solution, you should respect my effort.
* I hope my code compiles and gets accepted.
* ___ __
* |\ \|\ \
* \ \ \_\ \
* \ \ ___ \emdan
* \ \ \\ \ \
* \ \__\\ \_\
* \|__| \|__|
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <algorithm>
#include <array>
#include <assert.h>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <locale>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define MP make_pair
#define PB push_back
#define eb emplace_back
#define endl '\n'
#define xx first
#define yy second
#define sz size()
#define vi vector<int>
#define vll vector<ll>
#define ul unsigned long
#define vs vector<string>
#define si set<int>
#define sll set<ll>
#define IO \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define all(v) ((v).begin()), ((v).end())
#define rall(v) ((v).rbegin()), ((v).rend())
#define Ceil(x, y) ((x + y - 1) / y)
#define lop(i, b, e) \
for (ll i = (b) - ((b) > (e)); i != (e) - ((b) > (e)); \
i += 1 - 2 * ((b) > (e)))
#define lopi(i, init, n, incr) for (ll i = init; i < n; i += incr)
#define Even(Num) Num % 2 == 0
#define mms(Arr, Value) memset(Arr, Value, sizeof(Arr))
#define SetPre(Ans, num) fixed << setprecision(num) << (Ans)
#define clr clear()
#define re return
#define print(ans) cout << ans << endl
#define print2(a, b) cout << a << ' ' << b << endl
#define vpii vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pi acos(-1)
#define fix(a, k) (ll(a) % ll(k) + k) % k
#define in insert
#define sc(n) cin >> n
#define sc2(n, m) cin >> n >> m
#define sc3(a, b, c) cin >> a >> b >> c
#define sc4(a, b, c, d) cin >> a >> b >> c >> d
#define watch(x) cout << (#x) << " is " << (x) << endl
#define stringToLower(s) transform(all(s), s.begin(), ::tolower);
#define stringToUpper(s) transform(all(s), s.begin(), ::toupper);
#define noOfDigits(n) (1 + floor(log10(n)))
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)
#define modulo(S, N) ((S) & (N - 1)) // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) \
((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))
#define posOfFirstSetBit(n) (log2(n & -n) + 1);
typedef long long int ll;
typedef long double ld;
typedef int8_t i8;
typedef uint8_t ui8;
typedef int16_t i16;
typedef uint16_t ui16;
typedef int32_t i32;
typedef uint32_t ui32;
typedef int64_t i64;
typedef uint64_t ui64;
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#ifdef _WIN64
#define __builtin_popcountll __popcnt64
#else
inline int __builtin_popcountll(__int64 a) {
return __builtin_popcount((ui32)a) + __builtin_popcount(a >> 32);
}
#endif
#endif
int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int oo = INT_MAX;
const ll OO = 1e18;
const int monthly[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int alldx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int alldy[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dx[] = {1, -1, 0, 0, 0, 0};
const int dy[] = {0, 0, 1, -1, 0, 0};
const int dz[] = {0, 0, 0, 0, 1, -1};
using namespace std;
string Letters = "0123456789ABCDEF";
int toInt(char c) { re Letters.find(c); }
ll FromAnyBaseToDecimal(string inp, int base) {
ll res = 0;
lop(i, 0, inp.sz) {
res *= base;
res += toInt(inp[i]);
}
re res;
}
string FromDecimalToAnyBase(ll n, int base) {
if (n == 0)
re "0";
string ans = "";
while (n) {
ans = Letters[n % base] + ans;
n /= base;
}
re ans;
}
ll GCD(ll a, ll b) { re((!b) ? a : GCD(b, a % b)); }
ll LCM(ll a, ll b) { re a / (GCD(a, b)) * b; }
ll nCr(ll n, ll r) {
if (n < r)
re 0;
if (r == 0)
re 1;
re n *nCr(n - 1, r - 1) / r;
}
ll PowMod(ll bs, ll ex, ll M) {
if (!ex)
re 1;
ll p = PowMod((bs * bs) % M, ex >> 1, M);
re(ex & 1) ? (p * bs) % M : p;
}
ll fastpow(ll b, ll e) {
if (!e)
re 1;
if (e & 1)
re b *fastpow(b, e - 1);
ll x = fastpow(b, e / 2);
re x *x;
}
ll ModInverse(ll a) { re PowMod(a, MOD - 2, MOD); }
ll ExtGCD(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1;
y = 0;
re a;
}
ll r = ExtGCD(b, a % b, y, x);
y -= a / b * x;
re r;
}
ll mult(ll a, ll b) { re(1LL * a * b) % MOD; }
ll SumOfOdd(ll l, ll r) {
ll Rsm = (r + 1) / 2;
Rsm *= Rsm;
l--;
ll Lsm = (l + 1) / 2;
Lsm *= Lsm;
re Rsm - Lsm;
}
ll NoOfOdd(ll L, ll R) {
ll N = (R - L) / 2;
if (R % 2 != 0 || L % 2 != 0)
N++;
re N;
}
ll NoOfEven(ll L, ll R) { re((R - L + 1) - NoOfOdd(L, R)); }
bool PointInRectangle(ll x1, ll y1, ll x2, ll y2, ll x, ll y) {
re(x >= x1 && x <= x2 && y >= y1 && y <= y2);
}
bool isPrime(ll n) {
if (n == 2)
re 1;
if (n < 2 || n % 2 == 0)
re 0;
for (ll i = 3; i * i <= n; i += 2)
if (n % i == 0)
re 0;
re 1;
}
bool isPalindrome(string str) {
ll l = 0;
ll h = str.sz - 1;
while (h > l) {
if (str[l++] != str[h--]) {
re 0;
}
}
re 1;
}
bool isPerfectSquare(ld x) {
ld sr = sqrt(x);
re((sr - floor(sr)) == 0);
}
bool isPerfectCube(ll n) {
ll curoot = round(pow(n, 1.0 / 3.0));
re(pow(curoot, 3) == n);
}
double distance(double x1, double y1, double x2, double y2) {
re hypot(fabs(x1 - x2), fabs(y1 - y2));
}
int main() {
IO;
ll n, k;
cin >> n >> k;
priority_queue<ll> pq;
lop(i, 0, n) {
ll x;
cin >> x;
pq.push(x);
}
while (k--) {
ll tp = pq.top();
pq.pop();
pq.push(tp >> 1);
}
ll sm = 0;
while (!pq.empty()) {
sm += pq.top();
pq.pop();
}
cout << sm << endl;
}
| delete | 256 | 263 | 256 | 256 | TLE | |
p02912 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cout << setprecision(10) << fixed;
int n, m;
cin >> n >> m;
priority_queue<long long> pq;
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
pq.push(x);
}
for (int i = 0; i < m; ++i) {
long long nn = pq.top();
pq.pop();
nn /= 2;
if (nn) {
pq.push(nn);
}
}
long long ans = 0;
while (pq.size()) {
long long nn = pq.top();
pq.pop();
ans += nn;
}
cout << ans;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cout << setprecision(10) << fixed;
int n, m;
cin >> n >> m;
priority_queue<long long> pq;
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
pq.push(x);
}
for (int i = 0; i < m; ++i) {
long long nn = pq.top();
pq.pop();
nn /= 2;
pq.push(nn);
}
long long ans = 0;
while (pq.size()) {
long long nn = pq.top();
pq.pop();
ans += nn;
}
cout << ans;
return 0;
}
| replace | 18 | 21 | 18 | 19 | TLE | |
p02912 | C++ | Time Limit Exceeded | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
const ll mod = 1e9 + 7;
const int inf = 1 << 30;
int main() {
int n, m;
cin >> n >> m;
priority_queue<int> q;
rep(i, n) {
int a;
cin >> a;
q.push(a);
}
rep(i, m) {
int a = q.top();
a /= 2;
q.pop();
q.push(a);
}
ll ans = 0;
rep(i, n) {
ans += q.top();
q.pop();
}
cout << ans << endl;
} | // #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
const ll mod = 1e9 + 7;
const int inf = 1 << 30;
int main() {
int n, m;
cin >> n >> m;
priority_queue<int> q;
rep(i, n) {
int a;
cin >> a;
q.push(a);
}
rep(i, m) {
int a = q.top();
a /= 2;
q.pop();
q.push(a);
}
ll ans = 0;
rep(i, n) {
ans += q.top();
q.pop();
}
cout << ans << endl;
} | replace | 0 | 1 | 0 | 1 | TLE | |
p02912 | Python | Time Limit Exceeded | N, M = map(int, input().split())
A = list(map(int, input().split()))
while M > 0:
M -= 1
A[A.index(max(A))] //= 2
print(sum(A))
| import heapq
n, m = map(int, input().split())
a = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(a) # aを優先度付きキューに
for _ in range(m):
tmp_min = heapq.heappop(a)
heapq.heappush(a, (-1) * (-tmp_min // 2)) # 計算誤差の関係で-1を2回かけてます
print(-sum(a))
| replace | 0 | 6 | 0 | 10 | TLE | |
p02912 | Python | Time Limit Exceeded | N, M = map(int, input().split())
A = list(map(int, input().split()))
while M > 0:
max_index = A.index(max(A))
A[max_index] = A[max_index] // 2
M -= 1
print(sum(A))
| N, M = map(int, input().split())
A = list(map(int, input().split()))
while M > 0:
A.sort(reverse=True)
if A[0] == 0:
break
ham = A[0] // 2
for i, a in enumerate(A):
if ham < a and M > 0:
A[i] = A[i] // 2
M -= 1
else:
break
print(sum(A))
| replace | 4 | 7 | 4 | 14 | TLE | |
p02912 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s, i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
int main() {
ll n, m;
cin >> n >> m;
vector<ll> a;
map<ll, ll> mp;
multiset<ll> ms;
ll x;
rep(i, n) {
cin >> x;
ms.insert(x);
}
ll ans = 0;
rep(i, m) {
auto itr = ms.rbegin();
ms.insert((*itr) / 2);
ms.erase(*itr);
}
for (auto itr = ms.begin(); itr != ms.end(); ++itr) {
ans += *itr;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s, i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
int main() {
ll n, m;
cin >> n >> m;
vector<ll> a;
map<ll, ll> mp;
multiset<ll> ms;
ll x;
rep(i, n) {
cin >> x;
ms.insert(x);
}
ll ans = 0;
rep(i, m) {
auto itr = ms.rbegin();
ms.insert((*itr) >> 1);
ms.erase(ms.find(*itr));
}
for (auto itr = ms.begin(); itr != ms.end(); ++itr) {
ans += *itr;
}
cout << ans << endl;
return 0;
} | replace | 21 | 23 | 21 | 23 | 0 | |
p02912 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
int n, m, a;
cin >> n >> m;
vector<int> p(n);
for (int i = 0; i < n; i++) {
cin >> a;
p[i] = a;
}
sort(p.begin(), p.end());
for (int i = 0; i < m; i++) {
p[n - 1] = p[n - 1] / 2;
sort(p.begin(), p.end());
}
ll sum = 0;
for (int i = 0; i < n; i++) {
sum += p[i];
}
cout << sum;
return 0;
} | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
int n, m, a;
cin >> n >> m;
vector<int> p(n);
for (int i = 0; i < n; i++) {
cin >> a;
p[i] = a;
}
sort(p.begin(), p.end(), greater<int>());
while (true) {
int half = p[0] / 2;
for (int i = 0; i < n && m > 0; i++) {
if (half >= p[i] || p[i] == 0) {
break;
}
p[i] = p[i] / 2;
m--;
}
if (m == 0) {
break;
}
sort(p.begin(), p.end(), greater<int>());
if (p[0] == 0) {
break;
}
}
ll sum = 0;
for (int i = 0; i < n; i++) {
sum += p[i];
}
cout << sum;
return 0;
} | replace | 12 | 16 | 12 | 29 | TLE | |
p02912 | C++ | Time Limit Exceeded | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
priority_queue<long long> que;
for (int i = 0; i < n; i++) {
long long ai;
cin >> ai;
que.push(ai);
}
for (int i = 0; i < m; i++) {
long long t;
t = que.top();
que.pop();
que.push(t / 2);
}
long long ans = 0;
while (!que.empty()) {
ans += que.top();
que.pop();
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
priority_queue<long long> que;
for (int i = 0; i < n; i++) {
long long ai;
cin >> ai;
que.push(ai);
}
for (int i = 0; i < m; i++) {
long long t;
t = que.top();
que.pop();
que.push(t / 2);
}
long long ans = 0;
while (!que.empty()) {
ans += que.top();
que.pop();
}
cout << ans << endl;
}
| delete | 0 | 1 | 0 | 0 | TLE | |
p02912 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main(void) {
int N, M;
cin >> N >> M;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
for (int j = 0; j < M; j++) {
std::vector<int>::iterator iter = std::max_element(A.begin(), A.end());
size_t index = std::distance(A.begin(), iter);
A[index] /= 2;
}
long long int sum = 0;
for (int i = 0; i < N; i++) {
sum += A[i];
}
cout << sum << endl;
return 0;
} | #include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main(void) {
int N, M;
cin >> N >> M;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
while (M > 0) {
sort(A.rbegin(), A.rend());
int mid = A[0] / 2;
for (int i = 0; i < N; i++) {
if (M > 0 && A[i] >= mid) {
A[i] /= 2;
M--;
} else {
break;
}
}
}
long long int sum = 0;
for (int i = 0; i < N; i++) {
sum += A[i];
}
cout << sum << endl;
return 0;
} | replace | 14 | 18 | 14 | 25 | TLE | |
p02912 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
priority_queue<int> q;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
}
for (int i = 0; i < M; i++) {
int a = q.top();
q.pop();
q.push(a / 2);
}
long long ans = 0;
for (int i = 0; i < N; i++) {
ans += q.top();
q.pop();
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
priority_queue<int> q;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
q.push(a);
}
for (int i = 0; i < M; i++) {
int a = q.top();
q.pop();
q.push(a / 2);
}
long long ans = 0;
for (int i = 0; i < N; i++) {
ans += q.top();
q.pop();
}
cout << ans << endl;
return 0;
} | insert | 10 | 10 | 10 | 11 | -11 | |
p02912 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <forward_list>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);
int main(void) {
int n, m;
int i;
priority_queue<int> a;
ll ans = 0;
cin >> n >> m;
for (i = 0; i < n; i++) {
int x;
cin >> x;
a.push(x);
}
for (i = 0; i < m; i++) {
int k = a.top();
a.pop();
a.push(k / 2);
}
for (i = 0; i < n;) {
ans += a.top();
a.pop();
}
cout << ans << endl;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <forward_list>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);
int main(void) {
int n, m;
int i;
priority_queue<int> a;
ll ans = 0;
cin >> n >> m;
for (i = 0; i < n; i++) {
int x;
cin >> x;
a.push(x);
}
for (i = 0; i < m; i++) {
int k = a.top();
a.pop();
a.push(k / 2);
}
for (i = 0; i < n; i++) {
ans += a.top();
a.pop();
}
cout << ans << endl;
} | replace | 41 | 42 | 41 | 42 | TLE | |
p02912 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX / 2;
int main() {
int N, M;
cin >> N >> M;
priority_queue<int> que;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
que.push(a);
}
for (int i = 0; i < M; i++) {
int mprice = que.top();
que.pop();
mprice /= 2;
if (mprice > 0)
que.push(mprice);
}
long ans = 0;
while (!que.empty()) {
ans += que.top();
que.pop();
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX / 2;
int main() {
int N, M;
cin >> N >> M;
priority_queue<int> que;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
que.push(a);
}
for (int i = 0; i < M; i++) {
int mprice = que.top();
que.pop();
que.push(mprice / 2);
}
long ans = 0;
while (!que.empty()) {
ans += que.top();
que.pop();
}
cout << ans << endl;
} | replace | 18 | 21 | 18 | 19 | TLE | |
p02912 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX / 2;
int main() {
int N, M;
cin >> N >> M;
priority_queue<int> que;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
que.push(a);
}
for (int i = 0; i < M; i++) {
int mprice = que.top();
que.pop();
mprice /= 2;
if (mprice != 0)
que.push(mprice);
}
long ans = 0;
while (!que.empty()) {
ans += que.top();
que.pop();
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX / 2;
int main() {
int N, M;
cin >> N >> M;
priority_queue<int> que;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
que.push(a);
}
for (int i = 0; i < M; i++) {
int mprice = que.top();
que.pop();
mprice /= 2;
que.push(mprice);
}
long ans = 0;
while (!que.empty()) {
ans += que.top();
que.pop();
}
cout << ans << endl;
} | replace | 19 | 21 | 19 | 20 | TLE | |
p02912 | C++ | Time Limit Exceeded | #define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod = 1e+9 + 7;
int main() {
ll n, m;
cin >> n >> m;
priority_queue<ll> q;
rep(i, n) {
ll a;
cin >> a;
q.push(a);
}
rep(i, m) {
ll t = q.top();
q.pop();
q.push(t / 2);
}
ll sum = 0;
while (!q.empty()) {
sum += q.top();
q.pop();
}
cout << sum << endl;
}
| // #define _GLIBCXX_DEBUG
#include <algorithm>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod = 1e+9 + 7;
int main() {
ll n, m;
cin >> n >> m;
priority_queue<ll> q;
rep(i, n) {
ll a;
cin >> a;
q.push(a);
}
rep(i, m) {
ll t = q.top();
q.pop();
q.push(t / 2);
}
ll sum = 0;
while (!q.empty()) {
sum += q.top();
q.pop();
}
cout << sum << endl;
}
| replace | 0 | 1 | 0 | 1 | TLE | |
p02912 | C++ | Time Limit Exceeded | /*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#define _GLIBCXX_DEBUG
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <limits> //setprecision
#include <string> // string, to_string, stoi
#include <tuple> // tuple, make_tuple
#include <utility> // pair, make_pair
#include <vector> // vector
// #include <cstdio> // printf
#include <cmath> //abs,,,
#include <deque> // deque
#include <map> // map
#include <math.h> //pow,,,
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
// #include <unordered_map> // unordered_map
// #include <unordered_set> // unordered_set
#include <bitset> // bitset
// #include <cctype> // isupper, islower, isdigit, toupper, tolower
// It is so troublesome that I include bits/stdc++.h !
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int, int> P;
// NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
if (M == 0)
return 1;
long long res = mod_pow((N * N) % MOD, M / 2);
// 最下位ビット(*N)が1の時は単独でNをかける
if (M & 1)
res = (res * N) % MOD;
return res %= MOD;
}
long long nCr(long long n, long long r) {
long long A = 1, B = 1;
// Aが分子Bが1/r!
for (long long i = n - r + 1; i <= n; i++) {
A = A * i % MOD;
}
for (long long i = 1; i <= r; i++) {
B = B * i % MOD;
}
B = mod_pow(B, MOD - 2);
B %= MOD;
// Bは割るのではなく掛ける
return (A * B) % MOD;
}
int main() {
int N, M;
scanf("%d%d", &N, &M);
long long ans = 0;
priority_queue<int> Q;
for (int i = 0; i < N; i++) {
int A;
scanf("%d", &A);
Q.push(A);
}
for (int i = 0; i < M; i++) {
int X = Q.top();
Q.pop();
Q.push(X / 2);
}
for (int i = 0; i < N; ++i) {
ans += Q.top();
Q.pop();
}
cout << ans << endl;
// PLEASE GIVE ME THE "ACCEPTED" !
}
| /*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <limits> //setprecision
#include <string> // string, to_string, stoi
#include <tuple> // tuple, make_tuple
#include <utility> // pair, make_pair
#include <vector> // vector
// #include <cstdio> // printf
#include <cmath> //abs,,,
#include <deque> // deque
#include <map> // map
#include <math.h> //pow,,,
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
// #include <unordered_map> // unordered_map
// #include <unordered_set> // unordered_set
#include <bitset> // bitset
// #include <cctype> // isupper, islower, isdigit, toupper, tolower
// It is so troublesome that I include bits/stdc++.h !
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int, int> P;
// NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
if (M == 0)
return 1;
long long res = mod_pow((N * N) % MOD, M / 2);
// 最下位ビット(*N)が1の時は単独でNをかける
if (M & 1)
res = (res * N) % MOD;
return res %= MOD;
}
long long nCr(long long n, long long r) {
long long A = 1, B = 1;
// Aが分子Bが1/r!
for (long long i = n - r + 1; i <= n; i++) {
A = A * i % MOD;
}
for (long long i = 1; i <= r; i++) {
B = B * i % MOD;
}
B = mod_pow(B, MOD - 2);
B %= MOD;
// Bは割るのではなく掛ける
return (A * B) % MOD;
}
int main() {
int N, M;
scanf("%d%d", &N, &M);
long long ans = 0;
priority_queue<int> Q;
for (int i = 0; i < N; i++) {
int A;
scanf("%d", &A);
Q.push(A);
}
for (int i = 0; i < M; i++) {
int X = Q.top();
Q.pop();
Q.push(X / 2);
}
for (int i = 0; i < N; ++i) {
ans += Q.top();
Q.pop();
}
cout << ans << endl;
// PLEASE GIVE ME THE "ACCEPTED" !
}
| delete | 3 | 4 | 3 | 3 | TLE | |
p02912 | C++ | Time Limit Exceeded | /*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#define _GLIBCXX_DEBUG
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <limits> //setprecision
#include <string> // string, to_string, stoi
#include <tuple> // tuple, make_tuple
#include <utility> // pair, make_pair
#include <vector> // vector
// #include <cstdio> // printf
#include <cmath> //abs,,,
#include <deque> // deque
#include <map> // map
#include <math.h> //pow,,,
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
// #include <unordered_map> // unordered_map
// #include <unordered_set> // unordered_set
#include <bitset> // bitset
// #include <cctype> // isupper, islower, isdigit, toupper, tolower
// It is so troublesome that I include bits/stdc++.h !
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int, int> P;
// NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
if (M == 0)
return 1;
long long res = mod_pow((N * N) % MOD, M / 2);
// 最下位ビット(*N)が1の時は単独でNをかける
if (M & 1)
res = (res * N) % MOD;
return res %= MOD;
}
long long nCr(long long n, long long r) {
long long A = 1, B = 1;
// Aが分子Bが1/r!
for (long long i = n - r + 1; i <= n; i++) {
A = A * i % MOD;
}
for (long long i = 1; i <= r; i++) {
B = B * i % MOD;
}
B = mod_pow(B, MOD - 2);
B %= MOD;
// Bは割るのではなく掛ける
return (A * B) % MOD;
}
int main() {
int N, M;
cin >> N >> M;
long long ans = 0;
priority_queue<long long> Q;
for (int i = 0; i < N; i++) {
int A;
cin >> A;
Q.push(A);
}
for (int i = 0; i < M; i++) {
long long X = Q.top();
Q.pop();
Q.push(X / 2);
}
while (!Q.empty()) {
ans += Q.top();
Q.pop();
}
cout << ans << endl;
// PLEASE GIVE ME THE "ACCEPTED" !
} | /*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
WRITER:kakitamasziru/OxOmisosiru
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <limits> //setprecision
#include <string> // string, to_string, stoi
#include <tuple> // tuple, make_tuple
#include <utility> // pair, make_pair
#include <vector> // vector
// #include <cstdio> // printf
#include <cmath> //abs,,,
#include <deque> // deque
#include <map> // map
#include <math.h> //pow,,,
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
// #include <unordered_map> // unordered_map
// #include <unordered_set> // unordered_set
#include <bitset> // bitset
// #include <cctype> // isupper, islower, isdigit, toupper, tolower
// It is so troublesome that I include bits/stdc++.h !
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
const long long INF = 100100100100100;
const int MOD = 1000000007;
typedef pair<int, int> P;
// NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
if (M == 0)
return 1;
long long res = mod_pow((N * N) % MOD, M / 2);
// 最下位ビット(*N)が1の時は単独でNをかける
if (M & 1)
res = (res * N) % MOD;
return res %= MOD;
}
long long nCr(long long n, long long r) {
long long A = 1, B = 1;
// Aが分子Bが1/r!
for (long long i = n - r + 1; i <= n; i++) {
A = A * i % MOD;
}
for (long long i = 1; i <= r; i++) {
B = B * i % MOD;
}
B = mod_pow(B, MOD - 2);
B %= MOD;
// Bは割るのではなく掛ける
return (A * B) % MOD;
}
int main() {
int N, M;
cin >> N >> M;
long long ans = 0;
priority_queue<long long> Q;
for (int i = 0; i < N; i++) {
int A;
cin >> A;
Q.push(A);
}
for (int i = 0; i < M; i++) {
long long X = Q.top();
Q.pop();
Q.push(X / 2);
}
while (!Q.empty()) {
ans += Q.top();
Q.pop();
}
cout << ans << endl;
// PLEASE GIVE ME THE "ACCEPTED" !
} | delete | 3 | 4 | 3 | 3 | TLE | |
p02912 | C++ | Runtime Error | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll>
#define VVI vector<vector<ll>>
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i, n) for (ll i = 0, _n = (n); (i) < (ll)_n; ++i)
#define REPR(i, n) for (ll i = (ll)(n)-1; 0 <= (i); --i)
#define RANGE(i, a, b) for (ll i = (ll)a, _b = (ll)(b); (i) < _b; ++i)
#define RANGER(i, a, b) for (ll i = (ll)(b)-1, _a = (ll)(a); (_a) <= i; --i)
#define FOR(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) \
(((b - a) * (double)rand() / RAND_MAX) + a) // [a, b)
#define UNIFORM_LL(a, b) (ll) UNIFORM_DOUBLE(a, b) // [a, b)
#define IN(v, lo, hi) ((lo) <= (v) && (v) < (hi))
#define DD(v) cout << #v << ": " << v << endl
#define FI first
#define SE second
template <typename T0, typename T1>
std::ostream &operator<<(std::ostream &os, const map<T0, T1> &v) {
for (typename map<T0, T1>::const_iterator p = v.begin(); p != v.end(); p++) {
os << p->first << ": " << p->second << " ";
}
return os;
}
template <typename T0, typename T1>
std::ostream &operator<<(std::ostream &os, const pair<T0, T1> &v) {
os << v.first << ": " << v.second << " ";
return os;
}
template <typename T>
std::ostream &operator<<(std::ostream &os, const vector<T> &v) {
for (int i = 0; i < (int)v.size(); i++) {
os << v[i] << " ";
}
return os;
}
template <typename T>
std::ostream &operator<<(std::ostream &os, const set<T> &v) {
vector<T> tmp(v.begin(), v.end());
os << tmp;
return os;
}
template <typename T>
std::ostream &operator<<(std::ostream &os, const deque<T> &v) {
vector<T> tmp(v.begin(), v.end());
os << tmp;
return os;
}
template <typename T>
std::ostream &operator<<(std::ostream &os, const vector<vector<T>> &v) {
for (int i = 0; i < (int)v.size(); i++) {
os << v[i] << endl;
}
return os;
}
template <typename T> void maxUpdate(T &a, T b) { a = max(a, b); }
template <typename T> void minUpdate(T &a, T b) { a = min(a, b); }
#define INF (1LL << 60)
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N, M;
while (cin >> N >> M) {
VI A(N);
REP(i, N) cin >> A[i];
VI dis;
ll ans = 0;
REP(i, N) {
ans += A[i];
ll den = 2;
REP(mi, M) {
ll v = A[i] / (den / 2) - A[i] / den;
if (v == 0)
break;
dis.PB(v);
den *= 2;
}
}
sort(ALLR(dis));
REP(i, M) ans -= dis[i];
cout << ans << endl;
}
return 0;
}
| #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
#define _USE_MATH_DEFINES
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
using namespace std;
#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll>
#define VVI vector<vector<ll>>
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i, n) for (ll i = 0, _n = (n); (i) < (ll)_n; ++i)
#define REPR(i, n) for (ll i = (ll)(n)-1; 0 <= (i); --i)
#define RANGE(i, a, b) for (ll i = (ll)a, _b = (ll)(b); (i) < _b; ++i)
#define RANGER(i, a, b) for (ll i = (ll)(b)-1, _a = (ll)(a); (_a) <= i; --i)
#define FOR(i, c) \
for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) \
(((b - a) * (double)rand() / RAND_MAX) + a) // [a, b)
#define UNIFORM_LL(a, b) (ll) UNIFORM_DOUBLE(a, b) // [a, b)
#define IN(v, lo, hi) ((lo) <= (v) && (v) < (hi))
#define DD(v) cout << #v << ": " << v << endl
#define FI first
#define SE second
template <typename T0, typename T1>
std::ostream &operator<<(std::ostream &os, const map<T0, T1> &v) {
for (typename map<T0, T1>::const_iterator p = v.begin(); p != v.end(); p++) {
os << p->first << ": " << p->second << " ";
}
return os;
}
template <typename T0, typename T1>
std::ostream &operator<<(std::ostream &os, const pair<T0, T1> &v) {
os << v.first << ": " << v.second << " ";
return os;
}
template <typename T>
std::ostream &operator<<(std::ostream &os, const vector<T> &v) {
for (int i = 0; i < (int)v.size(); i++) {
os << v[i] << " ";
}
return os;
}
template <typename T>
std::ostream &operator<<(std::ostream &os, const set<T> &v) {
vector<T> tmp(v.begin(), v.end());
os << tmp;
return os;
}
template <typename T>
std::ostream &operator<<(std::ostream &os, const deque<T> &v) {
vector<T> tmp(v.begin(), v.end());
os << tmp;
return os;
}
template <typename T>
std::ostream &operator<<(std::ostream &os, const vector<vector<T>> &v) {
for (int i = 0; i < (int)v.size(); i++) {
os << v[i] << endl;
}
return os;
}
template <typename T> void maxUpdate(T &a, T b) { a = max(a, b); }
template <typename T> void minUpdate(T &a, T b) { a = min(a, b); }
#define INF (1LL << 60)
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N, M;
while (cin >> N >> M) {
VI A(N);
REP(i, N) cin >> A[i];
VI dis;
ll ans = 0;
REP(i, N) {
ans += A[i];
ll den = 2;
REP(mi, M) {
ll v = A[i] / (den / 2) - A[i] / den;
if (v == 0)
break;
dis.PB(v);
den *= 2;
}
}
sort(ALLR(dis));
REP(i, min((ll)dis.size(), M)) ans -= dis[i];
cout << ans << endl;
}
return 0;
}
| replace | 113 | 114 | 113 | 114 | 0 | |
p02912 | C++ | Runtime Error | #include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll N = 2000009;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf = 1e14;
ll mod = 1e9 + 7;
ll powm(ll a, ll b) {
ll res = 1;
while (b) {
if (b & 1)
res = (res * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return res;
}
// ll fact[N];
// ll ncr(ll n,ll r){
// return (((fact[n]*powm(fact[r],mod-2))%mod)*powm(fact[n-r],mod-2))%mod;
// }
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll t = 1;
// cin>>t;
while (t--) {
ll n, m;
cin >> n >> m;
vector<ll> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
make_heap(a.begin(), a.end());
for (int i = 0; i < m; i++) {
ll k = a.front();
pop_heap(a.begin(), a.end());
a.pop_back();
k = k / 2;
a.push_back(k);
push_heap(a.begin(), a.end());
}
ll ans = 0;
for (auto i : a) {
ans += i;
}
cout << ans;
}
}
| #include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
const ll N = 2000009;
const ll p = 31;
const ll m = 1e9 + 7;
const ll inf = 1e14;
ll mod = 1e9 + 7;
ll powm(ll a, ll b) {
ll res = 1;
while (b) {
if (b & 1)
res = (res * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return res;
}
// ll fact[N];
// ll ncr(ll n,ll r){
// return (((fact[n]*powm(fact[r],mod-2))%mod)*powm(fact[n-r],mod-2))%mod;
// }
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
ll t = 1;
// cin>>t;
while (t--) {
ll n, m;
cin >> n >> m;
vector<ll> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
make_heap(a.begin(), a.end());
for (int i = 0; i < m; i++) {
ll k = a.front();
pop_heap(a.begin(), a.end());
a.pop_back();
k = k / 2;
a.push_back(k);
push_heap(a.begin(), a.end());
}
ll ans = 0;
for (auto i : a) {
ans += i;
}
cout << ans;
}
}
| replace | 28 | 32 | 28 | 32 | -6 | terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
|
p02912 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
int N, M;
cin >> N >> M;
priority_queue<long long> que;
for (int i = 0; i < N; i++) {
long long A;
cin >> A;
que.push(A);
}
for (int i = 0; i < M; i++) {
long long t = que.top();
que.pop();
que.push(t / 2);
}
long long ans = 0;
while (!que.empty())
ans += que.top();
que.pop();
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
int main() {
int N, M;
cin >> N >> M;
priority_queue<long long> que;
for (int i = 0; i < N; i++) {
long long A;
cin >> A;
que.push(A);
}
for (int i = 0; i < M; i++) {
long long t = que.top();
que.pop();
que.push(t / 2);
}
long long ans = 0;
while (!que.empty())
ans += que.top(), que.pop();
cout << ans << endl;
} | replace | 21 | 23 | 21 | 22 | TLE | |
p02912 | C++ | Runtime Error | #include <bits //stdc++.h>
using namespace std;
int main(void) {
unsigned long long a, b, c, d, i, j, ans;
ans = 0;
cin >> a >> b;
vector<unsigned long long> v;
v.push_back(0);
for (i = 0; i < a; i++) {
cin >> c;
ans = ans + c;
while (c) {
d = c / 2;
v.push_back(c - d);
c = d;
}
}
sort(v.begin(), v.end());
j = v.size();
for (i = 0; i < b; i++) {
ans = ans - v[j - 1 - i];
}
cout << ans << endl;
}
| #include <bits //stdc++.h>
using namespace std;
int main(void) {
unsigned long long a, b, c, d, i, j, ans;
ans = 0;
cin >> a >> b;
vector<unsigned long long> v;
v.push_back(0);
for (i = 0; i < a; i++) {
cin >> c;
ans = ans + c;
while (c) {
d = c / 2;
v.push_back(c - d);
c = d;
}
}
sort(v.begin(), v.end());
j = v.size();
if (j < b)
b = j;
for (i = 0; i < b; i++) {
ans = ans - v[j - 1 - i];
}
cout << ans << endl;
}
| insert | 19 | 19 | 19 | 21 | 0 | |
p02912 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
long long a[n];
std::vector<long long> v;
for (int i = 0; i < n; ++i) {
cin >> a[i];
v.push_back(a[i]);
}
// sort(v.begin(), v.end());
for (int i = 0; i < m; ++i) {
sort(v.begin(), v.end());
v[v.size() - 1] /= 2;
}
cout << accumulate(v.begin(), v.end(), 0LL) << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
long long a[n];
std::vector<long long> v;
for (int i = 0; i < n; ++i) {
cin >> a[i];
v.push_back(a[i]);
}
/*
for (int i = 0; i < m; ++i) {
sort(v.begin(), v.end());
v[v.size()-1] /= 2;
}
*/
make_heap(v.begin(), v.end());
for (int i = 0; i < m; i++) {
long long a = v.front();
pop_heap(v.begin(), v.end());
v.pop_back();
a = a / 2;
v.push_back(a);
push_heap(v.begin(), v.end());
}
cout << accumulate(v.begin(), v.end(), 0LL) << endl;
return 0;
}
| replace | 12 | 17 | 12 | 26 | TLE | |
p02912 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define N 2000000
typedef long long LL;
int a[N], tot, n, m;
LL sum;
int main() {
// freopen("sample.in", "r", stdin);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
int tmp;
scanf("%d", &tmp);
sum += tmp;
while (tmp) {
a[++tot] = tmp - tmp / 2, tmp /= 2;
}
}
if (m >= tot)
return cout << 0 << endl, 0;
nth_element(a + 1, a + tot - m + 1, a + tot + 1);
// for(int i = 1; i <= tot; i++) cout << a[i] << endl;
int kth = a[tot - m + 1], num = 0;
for (int i = 1; i <= tot; i++)
if (a[i] > kth)
sum -= a[i], num++;
sum = sum - (LL)kth * (m - num);
cout << sum << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define N 3000010
typedef long long LL;
int a[N], tot, n, m;
LL sum;
int main() {
// freopen("sample.in", "r", stdin);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
int tmp;
scanf("%d", &tmp);
sum += tmp;
while (tmp) {
a[++tot] = tmp - tmp / 2, tmp /= 2;
}
}
if (m >= tot)
return cout << 0 << endl, 0;
nth_element(a + 1, a + tot - m + 1, a + tot + 1);
// for(int i = 1; i <= tot; i++) cout << a[i] << endl;
int kth = a[tot - m + 1], num = 0;
for (int i = 1; i <= tot; i++)
if (a[i] > kth)
sum -= a[i], num++;
sum = sum - (LL)kth * (m - num);
cout << sum << endl;
} | replace | 2 | 3 | 2 | 3 | 0 | |
p02912 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bits/stdc++.h>
#include <ctype.h>
#include <float.h>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <string.h>
#include <string>
using namespace std;
int main() {
long long N, M, A[100000] = {}, ans = 0, max, l = 0;
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> A[i];
}
sort(A, A + N, greater<int>());
max = 0;
for (int i = 0; i < M; i++) {
for (int j = 0; j <= l + 1; j++) {
if (A[max] < A[j]) {
max = j;
}
}
A[max] /= 2;
if (l < max) {
l = max;
}
}
for (int i = 0; i < N; i++) {
ans += A[i];
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <bits/stdc++.h>
#include <ctype.h>
#include <float.h>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <string.h>
#include <string>
using namespace std;
int main() {
long long N, M, A[100000] = {}, ans = 0, max, l = 0;
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> A[i];
}
sort(A, A + N, greater<int>());
max = 0;
for (int i = 0; i < M; i++) {
for (int j = 0; j <= l + 1; j++) {
if (A[max] < A[j]) {
max = j;
}
}
A[max] /= 2;
if (l < max) {
l = max;
}
if (i == M / 2) {
sort(A, A + N, greater<int>());
l = 0;
}
}
for (int i = 0; i < N; i++) {
ans += A[i];
}
cout << ans << endl;
return 0;
} | insert | 33 | 33 | 33 | 38 | TLE | |
p02912 | C++ | Runtime Error | #include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int INF32 = 1 << 30;
const ll INF64 = 1LL << 60;
int main() {
#ifndef ONLINE_JUDGE
freopen(".in.txt", "r", stdin);
freopen(".out.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
priority_queue<ll> pq;
ll ans = 0;
for (int i = 0; i < n; i++) {
ll a;
cin >> a;
ans += a;
pq.push(a);
}
for (int i = 0; i < m; i++) {
ll t = pq.top();
pq.pop();
ans -= t / 2 + (t & 1);
pq.push(t / 2);
}
cout << ans;
return 0;
} | #include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int INF32 = 1 << 30;
const ll INF64 = 1LL << 60;
int main() {
// #ifndef ONLINE_JUDGE
// freopen(".in.txt", "r", stdin);
// freopen(".out.txt", "w", stdout);
// #endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
priority_queue<ll> pq;
ll ans = 0;
for (int i = 0; i < n; i++) {
ll a;
cin >> a;
ans += a;
pq.push(a);
}
for (int i = 0; i < m; i++) {
ll t = pq.top();
pq.pop();
ans -= t / 2 + (t & 1);
pq.push(t / 2);
}
cout << ans;
return 0;
} | replace | 16 | 20 | 16 | 20 | TLE | |
p02912 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};
int main() {
ll n, m;
cin >> n >> m;
vl a(n);
rep(i, n) cin >> a[i];
ll ng = -1, ok = 1e18;
while (ng + 1 < ok) {
ll x = (ng + ok) / 2;
ll cnt = 0;
vl b = a;
rep(i, n) {
while (b[i] > x) {
b[i] /= 2;
cnt++;
}
}
if (cnt > m)
ng = x;
else
ok = x;
}
rep(i, n) {
while (a[i] > ok) {
a[i] /= 2;
m--;
}
}
sort(all(a), greater<ll>());
rep(i, m) a[i] /= 2;
cout << accumulate(all(a), 0LL) << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for (ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};
int main() {
ll n, m;
cin >> n >> m;
vl a(n);
rep(i, n) cin >> a[i];
ll ng = -1, ok = 1e18;
while (ng + 1 < ok) {
ll x = (ng + ok) / 2;
ll cnt = 0;
vl b = a;
rep(i, n) {
while (b[i] > x) {
b[i] /= 2;
cnt++;
}
}
if (cnt > m)
ng = x;
else
ok = x;
}
rep(i, n) {
while (a[i] > ok) {
a[i] /= 2;
m--;
}
}
sort(all(a), greater<ll>());
rep(i, min(m, n)) a[i] /= 2;
cout << accumulate(all(a), 0LL) << endl;
} | replace | 43 | 44 | 43 | 44 | 0 | |
p02912 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, b) FOR(i, 0, b)
#define RFOR(i, a, b) for (int i = a - 1; i >= b; i--)
#define RREP(i, a) RFOR(i, a, 0)
#define REPALL(i, x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i, x) for (int i = x.size() - 1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x, num) count(ALL(x), num)
#define MEMSET(x, val) memset(x, val, sizeof(x))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
void YES(bool flag) { cout << (flag ? "YES" : "NO") << endl; }
void Yes(bool flag) { cout << (flag ? "Yes" : "No") << endl; }
void yes(bool flag) { cout << (flag ? "yes" : "no") << endl; }
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
int n, m;
map<ll, int> data;
int main() {
cin >> n >> m;
REP(i, n) {
int a;
cin >> a;
data[a]++;
}
while (m) {
auto mdata = MAX_ELEMENT(data);
if (mdata->first == 0) {
break;
}
if (m > mdata->scd) {
data[mdata->fst / 2] += mdata->scd;
m -= mdata->scd;
data.erase(mdata->fst);
} else {
data[mdata->fst / 2] += m;
data[mdata->fst] -= m;
break;
}
}
ll ans = 0ll;
for (auto itr = data.begin(); itr != data.end(); itr++) {
ans += itr->fst * itr->scd;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, b) FOR(i, 0, b)
#define RFOR(i, a, b) for (int i = a - 1; i >= b; i--)
#define RREP(i, a) RFOR(i, a, 0)
#define REPALL(i, x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i, x) for (int i = x.size() - 1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x, num) count(ALL(x), num)
#define MEMSET(x, val) memset(x, val, sizeof(x))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
void YES(bool flag) { cout << (flag ? "YES" : "NO") << endl; }
void Yes(bool flag) { cout << (flag ? "Yes" : "No") << endl; }
void yes(bool flag) { cout << (flag ? "yes" : "no") << endl; }
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
int n, m;
map<ll, int> data;
int main() {
cin >> n >> m;
REP(i, n) {
int a;
cin >> a;
data[a]++;
}
while (m) {
auto mdata = data.end();
mdata--;
if (mdata->fst == 0) {
break;
}
if (m > mdata->scd) {
data[mdata->fst / 2] += mdata->scd;
m -= mdata->scd;
data.erase(mdata->fst);
} else {
data[mdata->fst / 2] += m;
data[mdata->fst] -= m;
break;
}
}
ll ans = 0ll;
for (auto itr = data.begin(); itr != data.end(); itr++) {
ans += itr->fst * itr->scd;
}
cout << ans << endl;
return 0;
}
| replace | 42 | 44 | 42 | 45 | TLE | |
p02912 | C++ | Runtime Error | #include <bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define MOD 1000000007
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> a(N);
ll ans = 0;
rep(i, N) {
scanf("%d", &a[i]);
ans += a[i];
}
vector<int> x;
for (int i = 0; i < N; i++) {
while (a[i] >= 1) {
int X = a[i] % 2;
a[i] /= 2;
x.push_back(a[i] + X);
}
}
sort(x.begin(), x.end(), greater<int>());
for (int i = 0; i < M; i++) {
ans -= x[i];
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
typedef long long ll;
#define sz(x) int(x.size())
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define MOD 1000000007
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> a(N);
ll ans = 0;
rep(i, N) {
scanf("%d", &a[i]);
ans += a[i];
}
vector<int> x;
for (int i = 0; i < N; i++) {
while (a[i] >= 1) {
int X = a[i] % 2;
a[i] /= 2;
x.push_back(a[i] + X);
}
}
sort(x.begin(), x.end(), greater<int>());
for (int i = 0; i < M; i++) {
ans -= x[i];
if (ans < 0) {
ans = 0;
break;
}
}
cout << ans << endl;
return 0;
} | insert | 28 | 28 | 28 | 32 | 0 | |
p02913 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N;
cin >> N;
string S;
cin >> S;
int maxv = 0;
for (int i = 0; i < N; i++) {
char ch = S[i];
for (int j = i + 1; j < N; j++) {
if (S[j] != ch)
continue;
if (i + maxv > j || j + maxv > N)
continue;
int k = 0;
while (j + k < N && i + k < j && S[j + k] == S[i + k])
k++;
maxv = max(maxv, k);
}
}
cout << maxv << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N;
cin >> N;
string S;
cin >> S;
int maxv = 0;
for (int i = 0; i < N; i++) {
char ch = S[i];
for (int j = i + 1; j < N; j++) {
if (S[j] != ch)
continue;
if (i + maxv > j || j + maxv > N)
continue;
if (i > 0 && S[i - 1] == S[j - 1])
continue;
int k = 0;
while (j + k < N && i + k < j && S[j + k] == S[i + k])
k++;
maxv = max(maxv, k);
}
}
cout << maxv << endl;
return 0;
}
| insert | 19 | 19 | 19 | 21 | TLE | |
p02913 | C++ | Runtime Error | #pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, a, b) for (ll i = a; i < b; i++)
#define repr(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()
// #define int ll
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
ll n, ans = 0;
string s;
cin >> n >> s;
ll dp[6010][6010];
rep(i, 5010) rep(j, 5010) dp[i][j] = 0;
for (ll i = n - 1; i >= 0; i--) {
for (ll j = n - 1; j > i; j--) {
if (s[i] == s[j]) {
dp[i][j] = max(dp[i][j], dp[i + 1][j + 1] + 1);
}
ans = max(ans, min(dp[i][j], j - i));
}
}
cout << ans << endl;
return 0;
} | #pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, a, b) for (ll i = a; i < b; i++)
#define repr(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()
// #define int ll
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
ll n, ans = 0;
string s;
cin >> n >> s;
ll dp[5010][5010];
rep(i, 5010) rep(j, 5010) dp[i][j] = 0;
for (ll i = n - 1; i >= 0; i--) {
for (ll j = n - 1; j > i; j--) {
if (s[i] == s[j]) {
dp[i][j] = max(dp[i][j], dp[i + 1][j + 1] + 1);
}
ans = max(ans, min(dp[i][j], j - i));
}
}
cout << ans << endl;
return 0;
} | replace | 47 | 48 | 47 | 48 | -11 | |
p02913 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <set>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
void cinv(lls &llVec, ll n) {
ll val;
llVec.reserve((size_t)(n));
for (ll i = 0; i < n; i++) {
cin >> val;
llVec.push_back(val);
}
}
int main() {
ll N;
std::string S;
cin >> N >> S;
ll maxLen = 0;
for (ll i = 0; i < N - 1; i++) {
for (ll j = i + 1; j < N; j++) {
// if (i != 0) {
// if (S[i - 1] == S[j - 1]) break;
// }
ll k;
for (k = 0; i + k < j; k++) {
char cik = S[i + k];
char cjk = S[j + k];
if (cik != cjk)
break;
}
maxLen = MAX(maxLen, k);
}
}
cout << maxLen << '\n';
return 0;
}
| #include <algorithm>
#include <iostream>
#include <set>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
void cinv(lls &llVec, ll n) {
ll val;
llVec.reserve((size_t)(n));
for (ll i = 0; i < n; i++) {
cin >> val;
llVec.push_back(val);
}
}
int main() {
ll N;
std::string S;
cin >> N >> S;
ll maxLen = 0;
for (ll i = 0; i < N - 1; i++) {
for (ll j = i + 1; j < N; j++) {
if (i != 0) {
if (S[i - 1] == S[j - 1])
continue;
}
ll k;
for (k = 0; i + k < j; k++) {
char cik = S[i + k];
char cjk = S[j + k];
if (cik != cjk)
break;
}
maxLen = MAX(maxLen, k);
}
}
cout << maxLen << '\n';
return 0;
}
| replace | 30 | 33 | 30 | 34 | TLE | |
p02913 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9 + 7;
constexpr ll MOD1 = 998244353;
typedef pair<ll, ll> P;
// #define all(v) (v).begin(), (v).end()
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) rep(i, 0, n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
// #define mp make_pair
int n;
string s;
void input() { cin >> n >> s; }
void solve() {
int ans = 0;
for (int i = 0; i < sz(s); i++) {
for (int j = i + 1; j < sz(s); j++) {
if (s[i] != s[j])
continue;
int cnt = 1;
for (int k = 1; j + k < sz(s); k++) {
if (s[i + k] == s[j + k] && i + k < j)
cnt++;
else
break;
}
ans = max(ans, cnt);
}
}
cout << ans << endl;
}
int main(int argc, char *argv[]) {
input();
solve();
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr long double EPS = 1e-15;
const long double PI = acos(-1);
constexpr int inf = 1e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9 + 7;
constexpr ll MOD1 = 998244353;
typedef pair<ll, ll> P;
// #define all(v) (v).begin(), (v).end()
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) rep(i, 0, n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
// #define mp make_pair
int n;
string s;
void input() { cin >> n >> s; }
void solve() {
int ans = 0;
for (int i = 1; i < sz(s); i++) {
int t = 0;
for (int j = 0; j + i < sz(s); j++) {
t = (t + 1) * (s[j] == s[j + i]);
ans = max(ans, min(t, i));
}
}
cout << ans << endl;
}
int main(int argc, char *argv[]) {
input();
solve();
return 0;
}
| replace | 27 | 39 | 27 | 32 | TLE | |
p02913 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(), a.end()
#define rrng(a) a.end(), a.begin()
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N;
string S;
cin >> N >> S;
int ans = 0;
for (int i = 1; i < N; i++) {
for (int j = 0; j < N; j++) {
int res = 0;
int m = j;
while (S[j] == S[j + i] && j < N && j + i < N && j < i + m) {
res++;
j++;
}
ans = max(res, ans);
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(), a.end()
#define rrng(a) a.end(), a.begin()
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N;
string S;
cin >> N >> S;
int ans = 0;
for (int i = 1; i < N; i++) {
for (int j = 0; j < N; j++) {
int res = 0;
int m = j;
while (j < N && j + i < N && S[j] == S[i + j] && j < i + m) {
res++;
j++;
}
ans = max(res, ans);
}
}
cout << ans << endl;
return 0;
}
| replace | 24 | 25 | 24 | 25 | 0 | |
p02913 | C++ | Runtime Error | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int N;
string S;
inline vector<int> Z_algorithm(string S) {
vector<int> Z(S.size());
Z[0] = S.size();
int i = 1, j = 0;
while (i < S.size()) {
while (i + j < S.size() && S[j] == S[i + j])
j++;
Z[i] = j;
if (j == 0) {
i++;
continue;
}
int k = 1;
while (k + Z[k] != j) {
Z[i + k] = Z[k];
k++;
}
i += k;
j -= k;
}
return Z;
}
signed main() {
cin >> N >> S;
ll ans = 0;
rep(i, N) {
string T = S.substr(i, N - i);
vector<int> v = Z_algorithm(T);
for (int j = 1; j < v.size(); j++) {
if (v[j] <= j)
ans = max(ans, (ll)v[j]);
}
}
cout << ans << endl;
}
| #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int N;
string S;
inline vector<int> Z_algorithm(string S) {
vector<int> Z(S.size());
Z[0] = S.size();
int i = 1, j = 0;
while (i < S.size()) {
while (i + j < S.size() && S[j] == S[i + j])
j++;
Z[i] = j;
if (j == 0) {
i++;
continue;
}
int k = 1;
while (i + k < S.size() && k + Z[k] < j) {
Z[i + k] = Z[k];
k++;
}
i += k;
j -= k;
}
return Z;
}
signed main() {
cin >> N >> S;
ll ans = 0;
rep(i, N) {
string T = S.substr(i, N - i);
vector<int> v = Z_algorithm(T);
for (int j = 1; j < v.size(); j++) {
if (v[j] <= j)
ans = max(ans, (ll)v[j]);
}
}
cout << ans << endl;
}
| replace | 33 | 34 | 33 | 34 | -11 | |
p02913 | C++ | Time Limit Exceeded | #include <iostream>
#include <vector>
using namespace std;
int n;
string s;
struct RollingHash {
vector<unsigned long long> hash[2], power[2];
const unsigned int seed = 10007;
const unsigned int mod[2] = {999999937, 1000000007};
RollingHash(const string &s) {
int n = (int)s.size();
for (int m = 0; m < 2; ++m) {
hash[m].assign(n + 1, 0);
power[m].assign(n + 1, 1);
for (int i = 0; i < n; ++i) {
hash[m][i + 1] = (hash[m][i] * seed + s[i]) % mod[m];
power[m][i + 1] = power[m][i] * seed % mod[m];
}
}
}
// [l, r)
inline unsigned long long get_hash(int l, int r, int m = 0) {
unsigned long long ret =
(hash[m][r] - hash[m][l] * power[m][r - l] % mod[m] + mod[m]) % mod[m];
return ret;
}
};
inline bool C(int k, RollingHash &rh) {
for (int i = 0; i < n / 2 + n / 3; ++i)
for (int j = i + k; j < n - k + 1; ++j) {
if (s[i] != s[j])
continue;
if (rh.get_hash(i, i + k) == rh.get_hash(j, j + k))
return true;
}
return false;
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
cin >> n >> s;
RollingHash rh(s);
int ok = 0, ng = n / 2 + 1;
while (ng - ok > 1) {
int mid = (ok + ng) >> 1;
if (C(mid, rh))
ok = mid;
else
ng = mid;
}
cout << ok << '\n';
return 0;
} | #include <iostream>
#include <vector>
using namespace std;
int n;
string s;
struct RollingHash {
vector<unsigned long long> hash[2], power[2];
const unsigned int seed = 10007;
const unsigned int mod[2] = {999999937, 1000000007};
RollingHash(const string &s) {
int n = (int)s.size();
for (int m = 0; m < 2; ++m) {
hash[m].assign(n + 1, 0);
power[m].assign(n + 1, 1);
for (int i = 0; i < n; ++i) {
hash[m][i + 1] = (hash[m][i] * seed + s[i]) % mod[m];
power[m][i + 1] = power[m][i] * seed % mod[m];
}
}
}
// [l, r)
inline unsigned long long get_hash(int l, int r, int m = 0) {
unsigned long long ret =
(hash[m][r] - hash[m][l] * power[m][r - l] % mod[m] + mod[m]) % mod[m];
return ret;
}
};
inline bool C(int k, RollingHash &rh) {
for (int i = 0; i < n / 2 + n / 4; ++i)
for (int j = i + k; j < n - k + 1; ++j) {
if (s[i] != s[j])
continue;
if (rh.get_hash(i, i + k) == rh.get_hash(j, j + k))
return true;
}
return false;
}
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
cin >> n >> s;
RollingHash rh(s);
int ok = 0, ng = n / 2 + 1;
while (ng - ok > 1) {
int mid = (ok + ng) >> 1;
if (C(mid, rh))
ok = mid;
else
ng = mid;
}
cout << ok << '\n';
return 0;
} | replace | 34 | 35 | 34 | 35 | TLE | |
p02913 | C++ | Runtime Error | #include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;
template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
int main() {
char s[5050];
int n;
scanf("%d", &n);
scanf("%s", s);
int max = 0;
forn(i, n) {
int t = 0;
forn(j, n) {
t = (t + 1) * (s[j] == s[j + i]);
uax(max, min(i, t));
}
}
printf("%d", max);
} | #include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef double ld;
template <class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template <class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
int main() {
char s[5050];
int n;
scanf("%d", &n);
scanf("%s", s);
int max = 0;
forn(i, n) {
int t = 0;
forn(j, n - i) {
t = (t + 1) * (s[j] == s[j + i]);
uax(max, min(i, t));
}
}
printf("%d", max);
} | replace | 33 | 34 | 33 | 34 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.