buggy_code
stringlengths 11
625k
| fixed_code
stringlengths 17
625k
| bug_type
stringlengths 2
4.45k
| language
int64 0
8
| token_count
int64 5
200k
| change_count
int64 0
100
|
|---|---|---|---|---|---|
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define REP(i, x, y) for (int i = (x); i < (y); ++i)
#define MP(a, b) make_pair((a), (b))
#define F_ first
#define S_ second
typedef long long int lli;
typedef pair<int, int> Pi;
const int INF = 100000000;
const long long int INF_ = 1000000000000000000;
const int MAX_N = 1 << 17;
int n;
int dat[2 * MAX_N - 1];
int num[2 * MAX_N - 1];
void Init(int n_) {
n = 1;
while (n < n_)
n *= 2;
for (int i = 0; i < 2 * n - 1; ++i) {
if (n - 1 <= i) {
dat[i] = 0;
num[i] = i;
} else {
dat[i] = INT_MIN;
num[i] = -1;
}
}
}
void Update(int k, int a) {
k += n - 1;
dat[k] = a;
while (k > 0) {
// dat[k]=max(dat[k*2+1],dat[k*2+2]);
k = (k - 1) / 2;
if (dat[k * 2 + 1] >= dat[k * 2 + 2]) {
dat[k] = dat[k * 2 + 1];
num[k] = num[k * 2 + 1];
} else {
dat[k] = dat[k * 2 + 2];
num[k] = num[k * 2 + 2];
}
}
}
Pi Query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l)
return Pi(-1, INT_MIN);
if (a <= l && r <= b)
return Pi(num[k], dat[k]);
else {
Pi vl = Query(a, b, k * 2 + 1, l, (l + r) / 2);
Pi vr = Query(a, b, k * 2 + 2, (l + r) / 2, r);
if (vl.S_ >= vr.S_)
return vl;
else
return vr;
}
}
int main() {
int N, R, L;
cin >> N >> R >> L;
Init(N);
vector<int> t(N);
Pi tmp;
REP(i, 0, R) {
int D, T, X;
cin >> D >> T >> X;
--D;
Update(D, dat[D + n - 1] + X);
Pi p = Query(0, n, 0, 0, n);
if (i != 0)
t[tmp.F_] += T - tmp.S_;
// if(i!=0) cout << tmp.F_ << ' ' << T-tmp.S_ << endl;
tmp.F_ = p.F_ - n + 1;
tmp.S_ = T;
if (i == R - 1)
t[tmp.F_] += L - T;
}
int ans = -1, l = 0;
REP(i, 0, N) {
if (l < t[i]) {
ans = i + 1;
l = t[i];
}
}
/*
REP(i,0,2*n-1){
cout << i << ' ' << num[i] << ' ' << dat[i] << endl;
}
cout << endl;
*/
cout << ans << endl;
return 0;
}
|
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define REP(i, x, y) for (int i = (x); i < (y); ++i)
#define MP(a, b) make_pair((a), (b))
#define F_ first
#define S_ second
typedef long long int lli;
typedef pair<int, int> Pi;
const int INF = 100000000;
const long long int INF_ = 1000000000000000000;
const int MAX_N = 1 << 17;
int n;
int dat[2 * MAX_N - 1];
int num[2 * MAX_N - 1];
void Init(int n_) {
n = 1;
while (n < n_)
n *= 2;
for (int i = 0; i < 2 * n - 1; ++i) {
if (n - 1 <= i) {
dat[i] = 0;
num[i] = i;
} else {
dat[i] = INT_MIN;
num[i] = -1;
}
}
}
void Update(int k, int a) {
k += n - 1;
dat[k] = a;
while (k > 0) {
// dat[k]=max(dat[k*2+1],dat[k*2+2]);
k = (k - 1) / 2;
if (dat[k * 2 + 1] >= dat[k * 2 + 2]) {
dat[k] = dat[k * 2 + 1];
num[k] = num[k * 2 + 1];
} else {
dat[k] = dat[k * 2 + 2];
num[k] = num[k * 2 + 2];
}
}
}
Pi Query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l)
return Pi(-1, INT_MIN);
if (a <= l && r <= b)
return Pi(num[k], dat[k]);
else {
Pi vl = Query(a, b, k * 2 + 1, l, (l + r) / 2);
Pi vr = Query(a, b, k * 2 + 2, (l + r) / 2, r);
if (vl.S_ >= vr.S_)
return vl;
else
return vr;
}
}
int main() {
int N, R, L;
cin >> N >> R >> L;
Init(N);
vector<int> t(N);
Pi tmp;
REP(i, 0, R) {
int D, T, X;
cin >> D >> T >> X;
--D;
Update(D, dat[D + n - 1] + X);
Pi p = Query(0, n, 0, 0, n);
if (i != 0)
t[tmp.F_] += T - tmp.S_;
// if(i!=0) cout << tmp.F_ << ' ' << T-tmp.S_ << endl;
tmp.F_ = p.F_ - n + 1;
tmp.S_ = T;
if (i == R - 1)
t[tmp.F_] += L - T;
}
int ans = -1, l = INT_MIN;
REP(i, 0, N) {
if (l < t[i]) {
ans = i + 1;
l = t[i];
}
}
/*
REP(i,0,2*n-1){
cout << i << ' ' << num[i] << ' ' << dat[i] << endl;
}
cout << endl;
*/
cout << ans << endl;
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22]]
| 1
| 679
| 2
|
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9
const int MAX_N = 1 << 17;
typedef pair<int, int> pii;
class RMQ {
public:
int n;
pii dat[2 * MAX_N - 1];
void init(int n_) {
n = 1;
while (n < n_) {
n *= 2;
}
for (int i = 0; i < 2 * n - 1; i++) {
dat[i] = pii(-INF, -INF);
}
for (int i = 0; i < n_; i++) {
update(i, 0);
}
}
void update(int k, int a) {
int tk = k;
k += n - 1;
dat[k] = pii(a, -tk);
while (k > 0) {
k = (k - 1) / 2;
dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
pii query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l) {
return pii(-INF, -INF);
}
if (a <= l && r <= b) {
return dat[k];
} else {
pii vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
pii vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return max(vl, vr);
}
}
};
int main() {
int N, R, L;
RMQ rmq;
cin >> N >> R >> L;
rmq.init(N);
int d, t, x, pt = 0;
vector<int> point(N, 0);
for (int i = 0; i < R; i++) {
cin >> d >> t >> x;
d--;
point[-rmq.query(0, N, 0, 0, rmq.n).second] = t - pt;
rmq.update(d, x + rmq.dat[d + rmq.n - 1].first);
pt = t;
}
point[-rmq.query(0, N, 0, 0, rmq.n).second] = L - pt;
int res = -1, max = -INF;
for (int i = 0; i < N; i++) {
if (max < point[i]) {
max = point[i];
res = i + 1;
}
}
cout << res << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9
const int MAX_N = 1 << 17;
typedef pair<int, int> pii;
class RMQ {
public:
int n;
pii dat[2 * MAX_N - 1];
void init(int n_) {
n = 1;
while (n < n_) {
n *= 2;
}
for (int i = 0; i < 2 * n - 1; i++) {
dat[i] = pii(-INF, -INF);
}
for (int i = 0; i < n_; i++) {
update(i, 0);
}
}
void update(int k, int a) {
int tk = k;
k += n - 1;
dat[k] = pii(a, -tk);
while (k > 0) {
k = (k - 1) / 2;
dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
}
}
pii query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l) {
return pii(-INF, -INF);
}
if (a <= l && r <= b) {
return dat[k];
} else {
pii vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
pii vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return max(vl, vr);
}
}
};
int main() {
int N, R, L;
RMQ rmq;
cin >> N >> R >> L;
rmq.init(N);
int d, t, x, pt = 0;
vector<int> point(N, 0);
for (int i = 0; i < R; i++) {
cin >> d >> t >> x;
d--;
point[-rmq.query(0, N, 0, 0, rmq.n).second] += t - pt;
rmq.update(d, x + rmq.dat[d + rmq.n - 1].first);
pt = t;
}
point[-rmq.query(0, N, 0, 0, rmq.n).second] += L - pt;
int res = -1, max = -INF;
for (int i = 0; i < N; i++) {
if (max < point[i]) {
max = point[i];
res = i + 1;
}
}
cout << res << endl;
return 0;
}
|
[["-", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107]]
| 1
| 550
| 4
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define MAX_N (100001)
#define MAX_R (1000000)
#define max(x, y) ((x) > (y) ? (x) : (y))
void init(int data[], int n);
void updata(int data[], int k, int a, int n);
int query(int data[]);
int such(int data[], int k, int n);
int n_;
typedef struct {
int d, t, x;
} Rec;
int main() {
int score[4 * MAX_N - 1], time[4 * MAX_N - 1];
int r, l, n;
scanf("%d %d %d", &n, &r, &l);
n_ = n;
n = 1;
while (n < n_)
n *= 2;
init(score, n);
init(time, n);
int t_a = 0, t_b = 0;
int k, t, d, x;
for (int i = 0; i < r; i++) {
scanf("%d %d %d", &d, &t_a, &x);
k = such(score, 0, n);
if (t_b == 0)
t = t_a;
else
t = t_a - t_b;
t_b = t_a;
// printf("k=%d\n",k);
updata(time, k, time[k + n - 2] + t, n);
// printf("b\n");
updata(score, d, score[d + n - 2] + x, n);
/*printf("c");
printf("\n---------------\n");
printf("k = %d\n",k);
for(int i=0;i<n-1;i++){
printf("%d : score %d time %d\n",i,score[i],time[i]);
}
printf("- - - -\n");
for(int i=n-1;i<n*2-1;i++){
printf("%d : score %d time %d\n",i,score[i],time[i]);
}*/
}
k = such(score, 0, n);
t = l - t_b;
updata(time, k, time[k + n - 2] + t, n);
/*
printf("\n---------------\n");
printf("k = %d\n",k);
for(int i=0;i<n;i++){
printf("%d : score %d time %d\n",i,score[i],time[i]);
}
printf("- - - -\n");
for(int i=n;i<n*2;i++){
printf("%d : score %d time %d\n",i,score[i],time[i]);
}*/
printf("%d\n", such(time, 0, n));
}
void init(int data[], int n) {
for (int i = 0; i < n * 4 - 1; i++) {
data[i] = 0;
}
return;
}
void updata(int data[], int k, int a, int n) {
k = k + n - 2;
data[k] = a;
while (k > 0) {
k = (k - 1) / 2;
data[k] = max(data[k * 2 + 1], data[k * 2 + 2]);
}
return;
}
int query(int data[]) { return data[0]; }
int such(int data[], int k, int n) {
if (k >= n_)
return k - n + 2;
if (data[k] == data[k * 2 + 1])
return such(data, k * 2 + 1, n);
if (data[k] == data[k * 2 + 2])
return such(data, k * 2 + 2, n);
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define MAX_N (100001)
#define MAX_R (1000000)
#define max(x, y) ((x) > (y) ? (x) : (y))
void init(int data[], int n);
void updata(int data[], int k, int a, int n);
int query(int data[]);
int such(int data[], int k, int n);
int n_;
typedef struct {
int d, t, x;
} Rec;
int main() {
int score[4 * MAX_N - 1], time[4 * MAX_N - 1];
int r, l, n;
scanf("%d %d %d", &n, &r, &l);
n_ = n;
n = 1;
while (n < n_)
n *= 2;
init(score, n);
init(time, n);
int t_a = 0, t_b = 0;
int k, t, d, x;
for (int i = 0; i < r; i++) {
scanf("%d %d %d", &d, &t_a, &x);
k = such(score, 0, n);
if (t_b == 0)
t = t_a;
else
t = t_a - t_b;
t_b = t_a;
// printf("k=%d\n",k);
updata(time, k, time[k + n - 2] + t, n);
// printf("b\n");
updata(score, d, score[d + n - 2] + x, n);
/*printf("c");
printf("\n---------------\n");
printf("k = %d\n",k);
for(int i=0;i<n-1;i++){
printf("%d : score %d time %d\n",i,score[i],time[i]);
}
printf("- - - -\n");
for(int i=n-1;i<n*2-1;i++){
printf("%d : score %d time %d\n",i,score[i],time[i]);
}*/
}
k = such(score, 0, n);
t = l - t_b;
updata(time, k, time[k + n - 2] + t, n);
/*
printf("\n---------------\n");
printf("k = %d\n",k);
for(int i=0;i<n;i++){
printf("%d : score %d time %d\n",i,score[i],time[i]);
}
printf("- - - -\n");
for(int i=n;i<n*2;i++){
printf("%d : score %d time %d\n",i,score[i],time[i]);
}*/
printf("%d\n", such(time, 0, n));
}
void init(int data[], int n) {
for (int i = 0; i < n * 2 - 1; i++) {
data[i] = 0;
}
return;
}
void updata(int data[], int k, int a, int n) {
k = k + n - 2;
data[k] = a;
while (k > 0) {
k = (k - 1) / 2;
data[k] = max(data[k * 2 + 1], data[k * 2 + 2]);
}
return;
}
int query(int data[]) { return data[0]; }
int such(int data[], int k, int n) {
if (k >= n - 1)
return k - n + 2;
if (data[k] == data[k * 2 + 1])
return such(data, k * 2 + 1, n);
else if (data[k] == data[k * 2 + 2])
return such(data, k * 2 + 2, n);
}
|
[["-", 0, 7, 15, 16, 12, 16, 31, 16, 12, 13], ["+", 0, 7, 15, 16, 12, 16, 31, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95]]
| 1
| 581
| 7
|
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for (int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;
using T = tuple<int, int, int>;
using edge = struct { int to, cost; };
const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template <typename T> // Maximum
struct RMQ {
private:
int N = 1;
vector<T> node;
public:
RMQ(vector<T> vec) {
int size = vec.size();
while (N < size) {
N *= 2;
}
node.resize(2 * N - 1, make_pair(-llINF, 0));
REP(i, size) { node[i + N - 1] = vec[i]; }
for (int i = N - 2; 0 <= i; i--) {
node[i] = max(node[2 * i + 1], node[2 * i + 2]);
}
}
void update(int i, T value) {
i += (N - 1);
node[i] = value;
while (i > 0) {
i = (i - 1) / 2;
node[i] = max(node[2 * i + 1], node[2 * i + 2]);
}
}
T getMax(int a, int b, int i = 0, int l = 0, int r = -1) {
if (r < 0) {
r = N;
}
if (r <= a || b <= l) {
return P(-llINF, llINF);
}
if (a <= l && r <= b) {
return node[i];
}
T vl = getMax(a, b, 2 * i + 1, l, (l + r) / 2);
T vr = getMax(a, b, 2 * i + 2, (l + r) / 2, r);
return max(vl, vr);
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, R, L;
cin >> N >> R >> L;
vector<P> vec(N);
vector<ll> time(N, 0);
REP(i, N) { vec[i] = make_pair(0, -i); }
RMQ<P> rmq(vec);
vector<int> d(R), t(R), x(R);
REP(i, R) { cin >> d[i] >> t[i] >> x[i]; }
t.push_back(L);
time[0] = t[0];
REP(i, R) {
P pre = rmq.getMax(d[i] - 1, d[i]);
rmq.update(d[i] - 1, make_pair(pre.fi + x[i], pre.se));
P team = rmq.getMax(0, N);
time[-team.se] += (t[i + 1] - t[i]);
}
cout << min_element(ALL(time)) - time.begin() << endl;
return 0;
}
|
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for (int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;
using T = tuple<int, int, int>;
using edge = struct { int to, cost; };
const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template <typename T> // Maximum
struct RMQ {
private:
int N = 1;
vector<T> node;
public:
RMQ(vector<T> vec) {
int size = vec.size();
while (N < size) {
N *= 2;
}
node.resize(2 * N - 1, make_pair(-llINF, 0));
REP(i, size) { node[i + N - 1] = vec[i]; }
for (int i = N - 2; 0 <= i; i--) {
node[i] = max(node[2 * i + 1], node[2 * i + 2]);
}
}
void update(int i, T value) {
i += (N - 1);
node[i] = value;
while (i > 0) {
i = (i - 1) / 2;
node[i] = max(node[2 * i + 1], node[2 * i + 2]);
}
}
T getMax(int a, int b, int i = 0, int l = 0, int r = -1) {
if (r < 0) {
r = N;
}
if (r <= a || b <= l) {
return P(-llINF, llINF);
}
if (a <= l && r <= b) {
return node[i];
}
T vl = getMax(a, b, 2 * i + 1, l, (l + r) / 2);
T vr = getMax(a, b, 2 * i + 2, (l + r) / 2, r);
return max(vl, vr);
}
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, R, L;
cin >> N >> R >> L;
vector<P> vec(N);
vector<ll> time(N, 0);
REP(i, N) { vec[i] = make_pair(0, -i); }
RMQ<P> rmq(vec);
vector<int> d(R), t(R), x(R);
REP(i, R) { cin >> d[i] >> t[i] >> x[i]; }
t.push_back(L);
time[0] = t[0];
REP(i, R) {
P pre = rmq.getMax(d[i] - 1, d[i]);
rmq.update(d[i] - 1, make_pair(pre.fi + x[i], pre.se));
P team = rmq.getMax(0, N);
time[-team.se] += (t[i + 1] - t[i]);
}
cout << max_element(ALL(time)) - time.begin() + 1 << endl;
return 0;
}
|
[["-", 0, 16, 31, 16, 12, 16, 31, 2, 63, 22], ["+", 31, 16, 12, 16, 31, 16, 31, 2, 63, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 748
| 4
|
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
struct RMQ {
pair<int, int> DEF;
int n;
vector<pair<int, int>> d;
RMQ(int n) {
DEF = make_pair(-1e9, 1e9);
this->n = n;
d.resize(2 * n - 1);
rep(i, 2 * n - 1) d[i] = DEF;
}
void update(int k, int a) {
k += n - 1;
d[k] = make_pair(a, k - (n - 1));
while (k > 0) {
k = (k - 1) / 2;
d[k] = function(d[k * 2 + 1], d[k * 2 + 2]);
}
}
pair<int, int> query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l)
return DEF;
if (a <= l && r <= b)
return d[k];
pair<int, int> vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
pair<int, int> vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return function(vl, vr);
}
pair<int, int> query(int a, int b) { return query(a, b, 0, 0, n); }
pair<int, int> function(pair<int, int> l, pair<int, int> r) {
if (l.first > r.first)
return l;
if (l.first < r.first)
return r;
if (l.first < r.first)
return l;
return r;
}
};
int main() {
int n, r, l;
cin >> n >> r >> l;
int score[n], res[n];
RMQ rmq(n);
rep(i, n) rmq.update(i, 0);
rep(i, n) rmq.update(i, 0);
rep(i, n) res[i] = 0;
rep(i, n) score[i] = 0;
int pre = 0;
rep(i, r) {
int d, t, x;
cin >> d >> t >> x;
int k = rmq.query(0, n).second;
res[k] += t - pre;
--d;
score[d] += x;
rmq.update(d, score[d]);
pre = t;
}
int k = rmq.query(0, n).second;
res[k] += l - pre;
int mi = 0, mx = 0;
rep(i, n) if (mx < res[i]) {
mi = i;
mx = res[i];
}
cout << mi + 1 << endl;
}
|
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
struct RMQ {
pair<int, int> DEF;
int n;
vector<pair<int, int>> d;
RMQ(int n) {
DEF = make_pair(-1e9, 1e9);
this->n = n;
d.resize(2 * n - 1);
rep(i, 2 * n - 1) d[i] = DEF;
}
void update(int k, int a) {
k += n - 1;
d[k] = make_pair(a, k - (n - 1));
while (k > 0) {
k = (k - 1) / 2;
d[k] = function(d[k * 2 + 1], d[k * 2 + 2]);
}
}
pair<int, int> query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l)
return DEF;
if (a <= l && r <= b)
return d[k];
pair<int, int> vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
pair<int, int> vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
return function(vl, vr);
}
pair<int, int> query(int a, int b) { return query(a, b, 0, 0, n); }
pair<int, int> function(pair<int, int> l, pair<int, int> r) {
if (l.first > r.first)
return l;
if (l.first < r.first)
return r;
if (l.second < r.second)
return l;
return r;
}
};
int main() {
int n, r, l;
cin >> n >> r >> l;
int score[n], res[n];
RMQ rmq(n);
rep(i, n) rmq.update(i, 0);
rep(i, n) rmq.update(i, 0);
rep(i, n) res[i] = 0;
rep(i, n) score[i] = 0;
int pre = 0;
rep(i, r) {
int d, t, x;
cin >> d >> t >> x;
int k = rmq.query(0, n).second;
res[k] += t - pre;
--d;
score[d] += x;
rmq.update(d, score[d]);
pre = t;
}
int k = rmq.query(0, n).second;
res[k] += l - pre;
int mi = 0, mx = 0;
rep(i, n) if (mx < res[i]) {
mi = i;
mx = res[i];
}
cout << mi + 1 << endl;
}
|
[["-", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120], ["-", 0, 57, 15, 339, 51, 16, 12, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 16, 12, 118, 119, 120]]
| 1
| 636
| 4
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define each(itr, c) \
for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
typedef pair<int, int> pi;
const int INF = 1010101010;
int main() {
int n, Q;
scanf(" %d %d", &n, &Q);
vector<pi> s(n);
rep(i, n) {
int tmp;
scanf(" %d", &tmp);
s[i] = pi(tmp, i);
}
sort(all(s));
vector<int> x(n);
rep(i, n) x[i] = s[i].fi;
vector<int> f(n);
rep(i, n) f[s[i].se] = i;
set<int> leader;
while (Q--) {
char q[10];
int a;
scanf(" %s %d", q, &a);
if (q[0] == 'A')
leader.insert(f[a - 1]);
else if (q[0] == 'R')
leader.erase(f[a - 1]);
else {
int ng = -1, ok = INF;
while (ok - ng > 1) {
int mid = (ok + ng) / 2;
int ct = 0, cr = 0;
for (const int &idx : leader) {
int lidx = lower_bound(all(x), x[idx] - mid) - x.begin();
int ridx = upper_bound(all(x), x[idx]) - x.begin() - 1;
if (lidx < cr)
lidx = cr + 1;
ct += ridx - lidx + 1;
cr = ridx;
}
if (n - ct <= a)
ok = mid;
else
ng = mid;
}
if (ok == INF)
printf("NA\n");
else
printf("%d\n", ok);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define each(itr, c) \
for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
typedef pair<int, int> pi;
const int INF = 1010101010;
int main() {
int n, Q;
scanf(" %d %d", &n, &Q);
vector<pi> s(n);
rep(i, n) {
int tmp;
scanf(" %d", &tmp);
s[i] = pi(tmp, i);
}
sort(all(s));
vector<int> x(n);
rep(i, n) x[i] = s[i].fi;
vector<int> f(n);
rep(i, n) f[s[i].se] = i;
set<int> leader;
while (Q--) {
char q[10];
int a;
scanf(" %s %d", q, &a);
if (q[0] == 'A')
leader.insert(f[a - 1]);
else if (q[0] == 'R')
leader.erase(f[a - 1]);
else {
int ng = -1, ok = INF;
while (ok - ng > 1) {
int mid = (ok + ng) / 2;
int ct = 0, cr = -1;
for (const int &idx : leader) {
int lidx = lower_bound(all(x), x[idx] - mid) - x.begin();
int ridx = upper_bound(all(x), x[idx]) - x.begin() - 1;
if (lidx <= cr)
lidx = cr + 1;
ct += ridx - lidx + 1;
cr = ridx;
}
if (n - ct <= a)
ok = mid;
else
ng = mid;
}
if (ok == INF)
printf("NA\n");
else
printf("%d\n", ok);
}
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
| 1
| 437
| 4
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define X real()
#define Y imag()
typedef long double D;
typedef complex<D> P;
struct L {
P a, b;
};
typedef vector<P> Pol;
const D EPS = 1e-8;
int sig(D a, D b = 0) { return a < b - EPS ? -1 : a > b + EPS ? 1 : 0; }
bool near(P a, P b) { return !sig(norm(a - b)); }
namespace std {
bool operator<(P a, P b) { return sig(a.Y, b.Y) ? a.Y < b.Y : a.X < b.X; }
} // namespace std
D sr(D a) { return sqrt(max(a, (D)0)); }
D det(P a, P b) { return a.X * b.Y - a.Y * b.X; }
enum CCW { FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16 };
int ccw(P a, P b, P c) {
if (near(a, c) || near(b, c))
return ON;
int s = sig(det(b - a, c - a));
if (s)
return s > 0 ? LEFT : RIGHT;
return (a < b) == (b < c) ? FRONT : (c < a) == (a < b) ? BACK : ON;
}
D arg(P base, P a, P b) { return arg((b - base) / (a - base)); }
L sortBase;
bool lessArg(pair<P, int> a, pair<P, int> b) {
D ang1 = arg(sortBase.a, sortBase.b, a.first);
D ang2 = arg(sortBase.a, sortBase.b, b.first);
return sig(ang1, ang2) ? ang1 < ang2 : norm(a.first) < norm(b.first);
}
D aTri(D a, D b, D c) {
D s = (a + b + c) / 2;
return sr(s * (s - a) * (s - b) * (s - c));
}
int main() {
int n;
cin >> n;
vector<pair<P, int>> vp;
rep(i, n) {
D x, y;
cin >> x >> y;
vp.push_back(make_pair(P(x, y), i + 1));
}
D r[n];
vector<int> pol[n];
rep(i, n) r[i] = 1e9;
rep(i, n) {
sort(vp.begin(), vp.end());
sortBase = (L){vp[i].first, vp[i].first + P(0, 1)};
sort(vp.begin() + i + 1, vp.end(), lessArg);
D dp[n + 1][n][n];
int prv[n + 1][n][n];
rep(j, n) rep(k, n) rep(l, n) dp[j][k][l] = 1e9;
rep(j, n) if (j > i) {
dp[0][i][j] = 0;
prv[0][i][j] = -1;
rep(k, n) rep(l, j)
rep(m, j) if (ccw(vp[l].first, vp[m].first, vp[j].first) == LEFT) {
D val = dp[k][l][m] + aTri(abs(vp[i].first - vp[m].first),
abs(vp[m].first - vp[j].first),
abs(vp[j].first - vp[i].first));
if (val < dp[k + 1][m][j]) {
dp[k + 1][m][j] = val;
prv[k + 1][m][j] = l;
if (r[k + 1] > dp[k + 1][m][j]) {
r[k + 1] = dp[k + 1][m][j];
vector<int> p;
p.push_back(vp[j].second);
p.push_back(vp[m].second);
int pk = k + 1, pm = m, pj = j;
while (pk != 0) {
int pl = prv[pk][pm][pj];
p.push_back(vp[pl].second);
--pk;
pj = pm;
pm = pl;
}
reverse(p.begin(), p.end());
pol[k + 1] = p;
}
}
}
}
}
int q;
cin >> q;
rep(i, q) {
int k;
cin >> k;
k -= 2;
if (pol[k].empty())
cout << "NA" << endl;
rep(j, pol[k].size()) cout << pol[k][j]
<< (j != (int)pol[k].size() - 1 ? " " : "\n");
}
}
|
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
struct L {
P a, b;
};
typedef vector<P> Pol;
const D EPS = 1e-8;
int sig(D a, D b = 0) { return a < b - EPS ? -1 : a > b + EPS ? 1 : 0; }
bool near(P a, P b) { return !sig(norm(a - b)); }
namespace std {
bool operator<(P a, P b) { return sig(a.Y, b.Y) ? a.Y < b.Y : a.X < b.X; }
} // namespace std
D sr(D a) { return sqrt(max(a, (D)0)); }
D det(P a, P b) { return a.X * b.Y - a.Y * b.X; }
enum CCW { FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16 };
int ccw(P a, P b, P c) {
if (near(a, c) || near(b, c))
return ON;
int s = sig(det(b - a, c - a));
if (s)
return s > 0 ? LEFT : RIGHT;
return (a < b) == (b < c) ? FRONT : (c < a) == (a < b) ? BACK : ON;
}
D arg(P base, P a, P b) { return arg((b - base) / (a - base)); }
L sortBase;
bool lessArg(pair<P, int> a, pair<P, int> b) {
D ang1 = arg(sortBase.a, sortBase.b, a.first);
D ang2 = arg(sortBase.a, sortBase.b, b.first);
return sig(ang1, ang2) ? ang1 < ang2 : norm(a.first) < norm(b.first);
}
D aTri(D a, D b, D c) {
D s = (a + b + c) / 2;
return sr(s * (s - a) * (s - b) * (s - c));
}
int main() {
int n;
cin >> n;
vector<pair<P, int>> vp;
rep(i, n) {
D x, y;
cin >> x >> y;
vp.push_back(make_pair(P(x, y), i + 1));
}
D r[n];
vector<int> pol[n];
rep(i, n) r[i] = 1e9;
rep(i, n) {
sort(vp.begin(), vp.end());
sortBase = (L){vp[i].first, vp[i].first + P(0, 1)};
sort(vp.begin() + i + 1, vp.end(), lessArg);
D dp[n + 1][n][n];
int prv[n + 1][n][n];
rep(j, n + 1) rep(k, n) rep(l, n) dp[j][k][l] = 1e9;
rep(j, n) if (j > i) {
dp[0][i][j] = 0;
prv[0][i][j] = -1;
rep(k, n) rep(l, j)
rep(m, j) if (ccw(vp[l].first, vp[m].first, vp[j].first) == LEFT) {
D val = dp[k][l][m] + aTri(abs(vp[i].first - vp[m].first),
abs(vp[m].first - vp[j].first),
abs(vp[j].first - vp[i].first));
if (val < dp[k + 1][m][j]) {
dp[k + 1][m][j] = val;
prv[k + 1][m][j] = l;
if (r[k + 1] > dp[k + 1][m][j]) {
r[k + 1] = dp[k + 1][m][j];
vector<int> p;
p.push_back(vp[j].second);
p.push_back(vp[m].second);
int pk = k + 1, pm = m, pj = j;
while (pk != 0) {
int pl = prv[pk][pm][pj];
p.push_back(vp[pl].second);
--pk;
pj = pm;
pm = pl;
}
reverse(p.begin(), p.end());
pol[k + 1] = p;
}
}
}
}
}
int q;
cin >> q;
rep(i, q) {
int k;
cin >> k;
k -= 2;
if (pol[k].empty())
cout << "NA" << endl;
rep(j, pol[k].size()) cout << pol[k][j]
<< (j != (int)pol[k].size() - 1 ? " " : "\n");
}
}
|
[["-", 36, 36, 0, 30, 0, 134, 39, 86, 0, 96], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 1,174
| 3
|
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int J, Y;
void t(int j, int y, string str) {
if (j > J && y > Y)
return;
if (j == J && y == Y) {
cout << str << endl;
return;
}
if (j == 5 && y == 5) {
return;
}
if ((j <= 3 && y >= 5) || (j >= 5 && y <= 3)) {
return;
}
t(j + 1, y, str + "A");
t(j, y + 1, str + "B");
}
int main() {
scanf("%d %d", &J, &Y);
t(0, 0, "");
}
|
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int J, Y;
void t(int j, int y, string str) {
if (j > J || y > Y)
return;
if (j == J && y == Y) {
cout << str << endl;
return;
}
if (j == 5 && y == 5) {
return;
}
if ((j <= 3 && y >= 5) || (j >= 5 && y <= 3)) {
return;
}
t(j + 1, y, str + "A");
t(j, y + 1, str + "B");
}
int main() {
scanf("%d %d", &J, &Y);
t(0, 0, "");
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106]]
| 1
| 160
| 2
|
// ナニソレイミワカンナイ
#include <algorithm>
#include <cstdio>
int replacement[4][2][5] = {{{1, 2, 3, 15, 19}, {28, 29, 30, 16, 21}},
{{7, 8, 9, 13, 10}, {22, 23, 24, 18, 12}},
{{1, 4, 7, 10, 16}, {24, 27, 30, 21, 18}},
{{3, 6, 9, 12, 13}, {22, 25, 28, 19, 15}}};
int p[31];
bool isComplete() {
for (int i = 1; i <= 9; i++) {
if (p[i] != p[1]) {
return false;
}
}
for (int i = 22; i <= 30; i++) {
if (p[i] != p[22]) {
return false;
}
}
for (int i = 10; i <= 21; i++) {
if (p[i] != p[10 + (i - 10) / 3 * 3]) {
return false;
}
}
return true;
}
void replace(int index) {
for (int i = 0; i < 5; i++) {
std::swap(p[replacement[index][0][i]], p[replacement[index][1][i]]);
}
}
int dfs(int t) {
if (isComplete()) {
return t;
}
if (t >= 8) {
return 1001001001;
}
int res = 1001001001;
for (int i = 0; i < 6; i++) {
replace(i);
res = std::min(res, dfs(t + 1));
replace(i);
}
return res;
}
int main() {
int N;
scanf("%d", &N);
while (N--) {
for (int i = 1; i <= 30; i++) {
scanf("%d", p + i);
}
printf("%d\n", dfs(0));
}
}
|
// ???????????????????????¶?????????
#include <algorithm>
#include <cstdio>
int replacement[4][2][5] = {{{1, 2, 3, 15, 19}, {28, 29, 30, 16, 21}},
{{7, 8, 9, 13, 10}, {22, 23, 24, 18, 12}},
{{1, 4, 7, 10, 16}, {24, 27, 30, 21, 18}},
{{3, 6, 9, 12, 13}, {22, 25, 28, 19, 15}}};
int p[31];
bool isComplete() {
for (int i = 1; i <= 9; i++) {
if (p[i] != p[1]) {
return false;
}
}
for (int i = 22; i <= 30; i++) {
if (p[i] != p[22]) {
return false;
}
}
for (int i = 10; i <= 21; i++) {
if (p[i] != p[10 + (i - 10) / 3 * 3]) {
return false;
}
}
return true;
}
void replace(int index) {
for (int i = 0; i < 5; i++) {
std::swap(p[replacement[index][0][i]], p[replacement[index][1][i]]);
}
}
int dfs(int t) {
if (isComplete()) {
return t;
}
if (t >= 8) {
return 1001001001;
}
int res = 1001001001;
for (int i = 0; i < 4; i++) {
replace(i);
res = std::min(res, dfs(t + 1));
replace(i);
}
return res;
}
int main() {
int N;
scanf("%d", &N);
while (N--) {
for (int i = 1; i <= 30; i++) {
scanf("%d", p + i);
}
printf("%d\n", dfs(0));
}
}
|
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
| 1
| 450
| 2
|
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
class FC {
public:
int p[31];
int n;
bool is_over() {
return p[1] == p[2] && p[2] == p[3] && p[3] == p[4] && p[4] == p[5] &&
p[5] == p[6] && p[6] == p[7] && p[7] == p[8] && p[8] == p[9] &&
p[10] == p[11] && p[11] == p[12] && p[13] == p[14] &&
p[14] == p[15] && p[16] == p[17] && p[17] == p[18] &&
p[19] == p[20] && p[20] == p[21] && p[22] == p[23] &&
p[23] == p[24] && p[24] == p[25] && p[25] == p[26] &&
p[26] == p[27] && p[27] == p[28] && p[28] == p[29] && p[29] == p[30];
}
void rot1() {
swap(p[7], p[22]);
swap(p[8], p[23]);
swap(p[9], p[24]);
swap(p[13], p[18]);
swap(p[10], p[12]);
}
void rot2() {
swap(p[1], p[28]);
swap(p[2], p[29]);
swap(p[3], p[30]);
swap(p[15], p[16]);
swap(p[21], p[19]);
}
void rot3() {
swap(p[1], p[24]);
swap(p[4], p[27]);
swap(p[7], p[30]);
swap(p[10], p[21]);
swap(p[16], p[18]);
}
void rot4() {
swap(p[3], p[22]);
swap(p[6], p[25]);
swap(p[9], p[28]);
swap(p[12], p[19]);
swap(p[13], p[15]);
}
};
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
FC now;
for (int j = 1; j <= 30; j++) {
cin >> now.p[j];
}
now.n = 0;
queue<FC> que;
que.push(now);
while (!que.empty()) {
now = que.front();
que.pop();
if (now.is_over()) {
cout << now.n << endl;
break;
}
FC nex1 = now;
nex1.rot1();
nex1.n++;
que.push(nex1);
FC nex2 = now;
nex2.rot1();
nex2.n++;
que.push(nex2);
FC nex3 = now;
nex3.rot1();
nex3.n++;
que.push(nex3);
FC nex4 = now;
nex4.rot1();
nex4.n++;
que.push(nex4);
}
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
class FC {
public:
int p[31];
int n;
bool is_over() {
return p[1] == p[2] && p[2] == p[3] && p[3] == p[4] && p[4] == p[5] &&
p[5] == p[6] && p[6] == p[7] && p[7] == p[8] && p[8] == p[9] &&
p[10] == p[11] && p[11] == p[12] && p[13] == p[14] &&
p[14] == p[15] && p[16] == p[17] && p[17] == p[18] &&
p[19] == p[20] && p[20] == p[21] && p[22] == p[23] &&
p[23] == p[24] && p[24] == p[25] && p[25] == p[26] &&
p[26] == p[27] && p[27] == p[28] && p[28] == p[29] && p[29] == p[30];
}
void rot1() {
swap(p[7], p[22]);
swap(p[8], p[23]);
swap(p[9], p[24]);
swap(p[13], p[18]);
swap(p[10], p[12]);
}
void rot2() {
swap(p[1], p[28]);
swap(p[2], p[29]);
swap(p[3], p[30]);
swap(p[15], p[16]);
swap(p[21], p[19]);
}
void rot3() {
swap(p[1], p[24]);
swap(p[4], p[27]);
swap(p[7], p[30]);
swap(p[10], p[21]);
swap(p[16], p[18]);
}
void rot4() {
swap(p[3], p[22]);
swap(p[6], p[25]);
swap(p[9], p[28]);
swap(p[12], p[19]);
swap(p[13], p[15]);
}
};
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
FC now;
for (int j = 1; j <= 30; j++) {
cin >> now.p[j];
}
now.n = 0;
queue<FC> que;
que.push(now);
while (!que.empty()) {
now = que.front();
que.pop();
if (now.is_over()) {
cout << now.n << endl;
break;
}
FC nex1 = now;
nex1.rot1();
nex1.n++;
que.push(nex1);
FC nex2 = now;
nex2.rot2();
nex2.n++;
que.push(nex2);
FC nex3 = now;
nex3.rot3();
nex3.n++;
que.push(nex3);
FC nex4 = now;
nex4.rot4();
nex4.n++;
que.push(nex4);
}
}
return 0;
}
|
[["-", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120]]
| 1
| 773
| 6
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define pb push_back
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define dep(i, a, n) for (int i = (a); i >= (n); i--)
#define mod 1e9 + 7
__attribute__((constructor)) void initial() {
cin.tie(0);
ios::sync_with_stdio(false);
}
int match(string s) {
if (s[0] != s[1] || s[1] != s[2] || s[2] != s[3] || s[3] != s[4] ||
s[4] != s[5] || s[5] != s[6] || s[6] != s[7] || s[7] != s[8])
return 0;
if (s[9] != s[10] || s[10] != s[11])
return 0;
if (s[12] != s[13] || s[13] != s[14])
return 0;
if (s[15] != s[16] || s[16] != s[17])
return 0;
if (s[18] != s[19] || s[19] != s[20])
return 0;
if (s[21] != s[22] || s[22] != s[23] || s[23] != s[24] || s[24] != s[25] ||
s[25] != s[26] || s[26] != s[27] || s[27] != s[28] || s[28] != s[29])
return 0;
return 1;
}
string lswap(string s) {
swap(s[0], s[29]);
swap(s[1], s[28]);
swap(s[2], s[27]);
swap(s[14], s[15]);
swap(s[18], s[20]);
return s;
}
string rswap(string s) {
swap(s[6], s[23]);
swap(s[7], s[22]);
swap(s[8], s[21]);
swap(s[12], s[17]);
swap(s[9], s[11]);
return s;
}
string uswap(string s) {
swap(s[2], s[21]);
swap(s[5], s[24]);
swap(s[8], s[27]);
swap(s[11], s[18]);
swap(s[12], s[14]);
return s;
}
string sswap(string s) {
swap(s[0], s[23]);
swap(s[3], s[26]);
swap(s[6], s[29]);
swap(s[9], s[20]);
swap(s[15], s[17]);
return s;
}
int solve(string s, int c, int i) {
if (match(s) || c > 8)
return 8;
int a = 8, b = 8, d = 8, e = 8;
if (i != 1)
a = solve(lswap(s), c + 1, 1);
if (i != 2)
b = solve(rswap(s), c + 1, 2);
if (i != 3)
d = solve(uswap(s), c + 1, 3);
if (i != 4)
e = solve(sswap(s), c + 1, 4);
return min(min(a, b), min(d, e));
}
int main() {
int n;
cin >> n;
rep(i, 0, n) {
string a, s = "";
rep(i, 0, 30) {
cin >> a;
s += a;
}
cout << solve(s, 0, 0) << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define pb push_back
#define rep(i, a, n) for (int i = (a); i < (n); i++)
#define dep(i, a, n) for (int i = (a); i >= (n); i--)
#define mod 1e9 + 7
__attribute__((constructor)) void initial() {
cin.tie(0);
ios::sync_with_stdio(false);
}
int match(string s) {
if (s[0] != s[1] || s[1] != s[2] || s[2] != s[3] || s[3] != s[4] ||
s[4] != s[5] || s[5] != s[6] || s[6] != s[7] || s[7] != s[8])
return 0;
if (s[9] != s[10] || s[10] != s[11])
return 0;
if (s[12] != s[13] || s[13] != s[14])
return 0;
if (s[15] != s[16] || s[16] != s[17])
return 0;
if (s[18] != s[19] || s[19] != s[20])
return 0;
if (s[21] != s[22] || s[22] != s[23] || s[23] != s[24] || s[24] != s[25] ||
s[25] != s[26] || s[26] != s[27] || s[27] != s[28] || s[28] != s[29])
return 0;
return 1;
}
string lswap(string s) {
swap(s[0], s[27]);
swap(s[1], s[28]);
swap(s[2], s[29]);
swap(s[14], s[15]);
swap(s[18], s[20]);
return s;
}
string rswap(string s) {
swap(s[6], s[21]);
swap(s[7], s[22]);
swap(s[8], s[23]);
swap(s[12], s[17]);
swap(s[9], s[11]);
return s;
}
string uswap(string s) {
swap(s[2], s[21]);
swap(s[5], s[24]);
swap(s[8], s[27]);
swap(s[11], s[18]);
swap(s[12], s[14]);
return s;
}
string sswap(string s) {
swap(s[0], s[23]);
swap(s[3], s[26]);
swap(s[6], s[29]);
swap(s[9], s[20]);
swap(s[15], s[17]);
return s;
}
int solve(string s, int c, int i) {
if (match(s) || c >= 8)
return c;
int a = 8, b = 8, d = 8, e = 8;
if (i != 1)
a = solve(lswap(s), c + 1, 1);
if (i != 2)
b = solve(rswap(s), c + 1, 2);
if (i != 3)
d = solve(uswap(s), c + 1, 3);
if (i != 4)
e = solve(sswap(s), c + 1, 4);
return min(min(a, b), min(d, e));
}
int main() {
int n;
cin >> n;
rep(i, 0, n) {
string a, s = "";
rep(i, 0, 30) {
cin >> a;
s += a;
}
cout << solve(s, 0, 0) << endl;
}
}
|
[["-", 0, 2, 3, 4, 0, 69, 341, 342, 0, 13], ["+", 0, 2, 3, 4, 0, 69, 341, 342, 0, 13], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20], ["-", 0, 14, 8, 9, 0, 57, 64, 37, 0, 13], ["+", 0, 14, 8, 9, 0, 57, 64, 37, 0, 22]]
| 1
| 872
| 12
|
#include <stdio.h>
int next[200001];
int prev[200001];
int main() {
int N, M, Q;
int a, q;
int i, j, p = 0, r = 0;
scanf("%d %d %d", &N, &M, &Q);
for (i = 0; i < N; i++) {
next[i] = (i + 1) % N;
prev[i] = (i + N - 1) % N;
}
for (i = 0; i < M; i++) {
scanf("%d", &a);
for (j = 0; j < a; j++)
p = a % 2 == 1 ? prev[p] : next[p];
next[prev[p]] = next[p];
prev[next[p]] = prev[p];
r = next[p];
next[p] = -1;
prev[p] = -1;
p = r;
}
for (i = 0; i < Q; i++) {
scanf("%d", &q);
if (next[q] != -1)
printf("0\n");
else
printf("1\n");
}
return 0;
}
|
#include <stdio.h>
int next[200001];
int prev[200001];
int main() {
int N, M, Q;
int a, q;
int i, j, p = 0, r = 0;
scanf("%d %d %d", &N, &M, &Q);
for (i = 0; i < N; i++) {
next[i] = (i + 1) % N;
prev[i] = (i + N - 1) % N;
}
for (i = 0; i < M; i++) {
scanf("%d", &a);
for (j = 0; j < a; j++)
p = a % 2 == 1 ? prev[p] : next[p];
next[prev[p]] = next[p];
prev[next[p]] = prev[p];
r = next[p];
next[p] = -1;
prev[p] = -1;
p = r;
}
for (i = 0; i < Q; i++) {
scanf("%d", &q);
if (next[q] != -1)
printf("1\n");
else
printf("0\n");
}
return 0;
}
|
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 265
| 4
|
#include <iostream>
using namespace std;
struct students {
int num[200000];
};
int main() {
students prev, next;
int n, m, q;
int o, p = 0;
cin >> n >> m >> q;
for (int i = 0; i < n; i++) {
prev.num[i] = (i - 1 + n) % n;
next.num[i] = (i + 1) % n;
}
for (int i = 0; i < m; i++) {
cin >> n;
for (int j = 0; j < n; j++) {
p = n % 2 > 0 ? prev.num[p] : next.num[p];
}
o = p;
next.num[prev.num[p]] = next.num[p];
prev.num[next.num[p]] = prev.num[p];
p = next.num[p];
next.num[p] = -1;
prev.num[p] = -1;
}
for (int i = 0; i < q; i++) {
cin >> m;
cout << (prev.num[m] < 0 ? 0 : 1) << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
struct students {
int num[200000];
};
int main() {
students prev, next;
int n, m, q;
int o, p = 0;
cin >> n >> m >> q;
for (int i = 0; i < n; i++) {
prev.num[i] = (i - 1 + n) % n;
next.num[i] = (i + 1) % n;
}
for (int i = 0; i < m; i++) {
cin >> n;
for (int j = 0; j < n; j++) {
p = n % 2 > 0 ? prev.num[p] : next.num[p];
}
o = p;
next.num[prev.num[p]] = next.num[p];
prev.num[next.num[p]] = prev.num[p];
p = next.num[p];
next.num[o] = -1;
prev.num[o] = -1;
}
for (int i = 0; i < q; i++) {
cin >> m;
cout << (prev.num[m] < 0 ? 0 : 1) << endl;
}
return 0;
}
|
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
| 1
| 267
| 4
|
#include <algorithm>
#include <iostream>
#define INF 1000000000
#define f first
#define s second
using namespace std;
typedef pair<int, pair<int, int>> P;
typedef long long ll;
int n, d, tree[4][(1 << 19)];
P star[200001];
void update(int i, int flg, int x) {
i = i + (1 << 18) - 1;
tree[flg][i] = x;
while (i) {
i = (i - 1) / 2;
tree[flg][i] = max(tree[flg][i * 2 + 1], tree[flg][i * 2 + 2]);
}
}
int find(int a, int b, int ima, int L, int R, int flg) {
if (R <= a || b <= L)
return -INF;
if (a <= L && R <= b)
return tree[flg][ima];
int M = (L + R) / 2;
return max(find(a, b, ima * 2 + 1, L, M, flg),
find(a, b, ima * 2 + 2, M, R, flg));
}
int main() {
cin >> n >> d;
for (int i = 0; i < n; i++)
cin >> star[i].s.f >> star[i].s.s >> star[i].f;
sort(star, star + n);
for (int i = 0; i < 4; i++)
for (int j = 0; j < (1 << 19); j++)
tree[i][j] = -INF;
for (int i = 0; i < n; i++) {
update(i, 0, star[i].s.f); // max(x);
update(i, 1, star[i].s.s); // max(y);
update(i, 2, -star[i].s.f); // min(x);
update(i, 3, -star[i].s.s); // min(y);
}
long long S = 0;
int ima = 0;
for (int i = 0; i < n; i++) {
while (i != n && star[ima].f - star[i].f <= d)
ima++;
ll maxx = find(i, ima, 0, 0, (1 << 18), 0);
ll maxy = find(i, ima, 0, 0, (1 << 18), 1);
ll minx = find(i, ima, 0, 0, (1 << 18), 2);
ll miny = find(i, ima, 0, 0, (1 << 18), 3);
S = max(S, ((maxx + minx) * (maxy + miny)));
}
cout << S << endl;
return 0;
}
|
#include <algorithm>
#include <iostream>
#define INF 1000000000
#define f first
#define s second
using namespace std;
typedef pair<int, pair<int, int>> P;
typedef long long ll;
int n, d, tree[4][(1 << 19)];
P star[200001];
void update(int i, int flg, int x) {
i = i + (1 << 18) - 1;
tree[flg][i] = x;
while (i) {
i = (i - 1) / 2;
tree[flg][i] = max(tree[flg][i * 2 + 1], tree[flg][i * 2 + 2]);
}
}
int find(int a, int b, int ima, int L, int R, int flg) {
if (R <= a || b <= L)
return -INF;
if (a <= L && R <= b)
return tree[flg][ima];
int M = (L + R) / 2;
return max(find(a, b, ima * 2 + 1, L, M, flg),
find(a, b, ima * 2 + 2, M, R, flg));
}
int main() {
cin >> n >> d;
for (int i = 0; i < n; i++)
cin >> star[i].s.f >> star[i].s.s >> star[i].f;
sort(star, star + n);
for (int i = 0; i < 4; i++)
for (int j = 0; j < (1 << 19); j++)
tree[i][j] = -INF;
for (int i = 0; i < n; i++) {
update(i, 0, star[i].s.f); // max(x);
update(i, 1, star[i].s.s); // max(y);
update(i, 2, -star[i].s.f); // min(x);
update(i, 3, -star[i].s.s); // min(y);
}
long long S = 0;
int ima = 0;
for (int i = 0; i < n; i++) {
while (ima != n && star[ima].f - star[i].f <= d)
ima++;
ll maxx = find(i, ima, 0, 0, (1 << 18), 0);
ll maxy = find(i, ima, 0, 0, (1 << 18), 1);
ll minx = find(i, ima, 0, 0, (1 << 18), 2);
ll miny = find(i, ima, 0, 0, (1 << 18), 3);
S = max(S, ((maxx + minx) * (maxy + miny)));
}
cout << S << endl;
return 0;
}
|
[["-", 0, 52, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 31, 22]]
| 1
| 616
| 2
|
#include <stdio.h>
int main(void) {
int time, D, L;
scanf("%d %d", &D, L);
time = D / L + D % L;
printf("%d", time);
return 0;
}
|
#include <stdio.h>
int main(void) {
int time, D, L;
scanf("%d %d", &D, &L);
time = D / L + D % L;
printf("%d\n", time);
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 50
| 2
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int d, l, a, b;
int count = 0;
cin >> d >> l;
a = d / l;
count = a;
if (count != 0) {
b = d % l;
b = b / 1;
count = b;
}
cout << count << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int d, l, a, b;
int count = 0;
cin >> d >> l;
a = d / l;
count = a;
if (count != 0 || d < l) {
b = d % l;
b = b / 1;
count += b;
}
cout << count << endl;
return 0;
}
|
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]]
| 1
| 75
| 6
|
a,b=map(int,input().split())
c=a//b
d=a%b
e=c+b
print(e)
|
a,b=map(int,input().split())
c=a//b
d=a%b
e=c+d
print(e)
|
[["-", 0, 656, 0, 1, 0, 662, 12, 657, 12, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 22]]
| 5
| 35
| 2
|
#include <stdio.h>
int main(void) {
int a[101][3] = {0}, N, X, Y, Z, q, w, e, r, t, y, u, i = 0;
scanf("%d", &N);
scanf("%d", &X);
for (q = 0; q < X; q++) {
scanf("%d", &r);
a[r][0] = 1;
}
scanf("%d", &Y);
for (w = 0; w < Y; w++) {
scanf("%d", &t);
a[t][1] = 1;
}
scanf("%d", &Z);
for (e = 0; e < Z; e++) {
scanf("%d", &y);
a[y][2] = 1;
}
for (u = 1; u <= N; u++) {
if (a[u][0] == 0 && a[u][2] == 1 || a[u][1] == 1 && a[u][3] == 1)
i++;
}
printf("%d\n", i);
return 0;
}
|
#include <stdio.h>
int main(void) {
int a[101][3] = {0}, N, X, Y, Z, q, w, e, r, t, y, u, i = 0;
scanf("%d", &N);
scanf("%d", &X);
for (q = 0; q < X; q++) {
scanf("%d", &r);
a[r][0] = 1;
}
scanf("%d", &Y);
for (w = 0; w < Y; w++) {
scanf("%d", &t);
a[t][1] = 1;
}
scanf("%d", &Z);
for (e = 0; e < Z; e++) {
scanf("%d", &y);
a[y][2] = 1;
}
for (u = 1; u <= N; u++) {
if (a[u][0] == 0 && a[u][2] == 1 || a[u][1] == 1 && a[u][2] == 1)
i++;
}
printf("%d\n", i);
return 0;
}
|
[["-", 0, 16, 12, 16, 12, 16, 31, 69, 71, 13], ["+", 0, 16, 12, 16, 12, 16, 31, 69, 71, 13]]
| 0
| 266
| 2
|
#include <stdio.h>
int main(void) {
int ha, hb, ka, kb, a, b, c, d, ht, kt;
scanf("%d %d", &ha, &hb);
scanf("%d %d", &ka, &kb);
scanf("%d %d %d %d", &a, &b, &c, &d);
ht = ha * a + hb * b;
if (ha <= 10)
ht += (ha / 10) * c;
if (hb <= 20)
ht += (hb / 20) * d;
kt = ka * a + kb * b;
if (ka <= 10)
kt += (ka / 10) * c;
if (kb <= 20)
kt += (kb / 20) * d;
if (ht > kt)
printf("hiroshi\n");
if (kt > ht)
printf("kenjiro\n");
if (kt == ht)
printf("even");
}
|
#include <stdio.h>
int main(void) {
int ha, hb, ka, kb, a, b, c, d, ht, kt;
scanf("%d %d", &ha, &hb);
scanf("%d %d", &ka, &kb);
scanf("%d %d %d %d", &a, &b, &c, &d);
ht = ha * a + hb * b;
if (ha >= 10)
ht += (ha / 10) * c;
if (hb >= 20)
ht += (hb / 20) * d;
kt = ka * a + kb * b;
if (ka >= 10)
kt += (ka / 10) * c;
if (kb >= 20)
kt += (kb / 20) * d;
if (ht > kt)
printf("hiroshi\n");
if (kt > ht)
printf("kenjiro\n");
if (kt == ht)
printf("even\n");
}
|
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 200
| 9
|
#include <stdio.h>
int main(void) {
// Your code here!
int h1, h2, k1, k2, a, b, c, d;
scanf("%d%d%d%d%d%d%d%d", &h1, &h2, &k1, &k2, &a, &b, &c, &d);
if (h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d >
k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d) {
puts("hirosi");
} else if (h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d <
k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d) {
puts("kenjiro");
} else {
puts("even");
}
}
|
#include <stdio.h>
int main(void) {
// Your code here!
int h1, h2, k1, k2, a, b, c, d;
scanf("%d%d%d%d%d%d%d%d", &h1, &h2, &k1, &k2, &a, &b, &c, &d);
if (h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d >
k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d) {
puts("hiroshi");
} else if (h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d <
k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d) {
puts("kenjiro");
} else {
puts("even");
}
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 187
| 2
|
#include <stdio.h>
int main(void) {
int a, b, c, d, e, f, g, h, hi, ke;
scanf("%d %d", &a, &b);
scanf("%d %d", &c, &d);
scanf("%d %d %d %d", &e, &f, &g, &h);
hi = a * e + b * f + a / 10 * g + b / 20 * h;
ke = c * e + d * f + c / 10 * g + d / 20 * h;
if (hi = ke) {
printf("even\n");
} else if (hi > ke) {
printf("hiroshi\n");
} else {
printf("kenjiro\n");
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int a, b, c, d, e, f, g, h, hi, ke;
scanf("%d %d", &a, &b);
scanf("%d %d", &c, &d);
scanf("%d %d %d %d", &e, &f, &g, &h);
hi = a * e + b * f + a / 10 * g + b / 20 * h;
ke = c * e + d * f + c / 10 * g + d / 20 * h;
if (hi == ke) {
printf("even\n");
} else if (hi > ke) {
printf("hiroshi\n");
} else {
printf("kenjiro\n");
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 23, 0, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 60]]
| 0
| 166
| 2
|
#include <stdio.h>
int main(void) {
int h1, h2, k1, k2, a, b, c, d, g, m;
scanf("%d%d%d%d%d%d%d%d", &h1, &h2, &k1, &k2, &a, &b, &c, &d);
g = h1 * a + h2 * b + h1 / 10 * c + h2 / 20 * d;
m = k1 * a + k2 * b + k1 / 10 * c + k2 / 20 * d;
if (g < m) {
printf("kenji\n");
} else if (m < g) {
printf("hiroshi\n");
} else {
printf("even\n");
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int h1, h2, k1, k2, a, b, c, d, g, m;
scanf("%d%d%d%d%d%d%d%d", &h1, &h2, &k1, &k2, &a, &b, &c, &d);
g = h1 * a + h2 * b + h1 / 10 * c + h2 / 20 * d;
m = k1 * a + k2 * b + k1 / 10 * c + k2 / 20 * d;
if (g < m) {
printf("kenjiro\n");
} else if (m < g) {
printf("hiroshi\n");
} else {
printf("even\n");
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 152
| 2
|
#include <stdio.h>
int main(void) {
int a, b, c, d, e, f, g, h, i, j, k;
scanf("%d %d", &a, &b);
scanf("%d %d", &c, &d);
scanf("%d %d %d %d", &e, &f, &g, &h);
i = a * e + b * f;
j = c * e + d * f;
if (a >= 10) {
k = a / 10;
i = i + k * g;
}
if (c >= 10) {
k = c / 10;
j = j + k * g;
}
if (b >= 20) {
k = b / 20;
i = i + k * h;
}
if (d >= 20) {
k = d / 20;
j = j + k * h;
}
if (i > j) {
printf("hiroshi\n");
} else if (j < i) {
printf("kenjiro\n");
} else if (i == j) {
printf("even\n");
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int a, b, c, d, e, f, g, h, i, j, k;
scanf("%d %d", &a, &b);
scanf("%d %d", &c, &d);
scanf("%d %d %d %d", &e, &f, &g, &h);
i = a * e + b * f;
j = c * e + d * f;
if (a >= 10) {
k = a / 10;
i = i + k * g;
}
if (c >= 10) {
k = c / 10;
j = j + k * g;
}
if (b >= 20) {
k = b / 20;
i = i + k * h;
}
if (d >= 20) {
k = d / 20;
j = j + k * h;
}
if (i > j) {
printf("hiroshi\n");
} else if (j > i) {
printf("kenjiro\n");
} else if (i == j) {
printf("even\n");
}
return 0;
}
|
[["-", 75, 76, 0, 57, 15, 23, 0, 16, 17, 18], ["+", 75, 76, 0, 57, 15, 23, 0, 16, 17, 47]]
| 0
| 238
| 2
|
#include <stdio.h>
int main() {
int k1, k2, h1, h2, a, b, c, d;
scanf("%d %d\n%d %d\n %d %d %d %d\n", &h1, &h2, &k1, &k2, &a, &b, &c, &d);
int hiro, ken;
hiro = h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d;
ken = k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d;
if (hiro < ken) {
printf("kenjiro\n");
} else if (hiro == ken) {
printf("even\n");
} else {
printf("hiroto\n");
}
return 0;
}
|
#include <stdio.h>
int main() {
int k1, k2, h1, h2, a, b, c, d;
scanf("%d %d\n%d %d\n %d %d %d %d\n", &h1, &h2, &k1, &k2, &a, &b, &c, &d);
int hiro, ken;
hiro = h1 * a + h2 * b + (h1 / 10) * c + (h2 / 20) * d;
ken = k1 * a + k2 * b + (k1 / 10) * c + (k2 / 20) * d;
if (hiro < ken) {
printf("kenjiro\n");
} else if (hiro == ken) {
printf("even\n");
} else {
printf("hiroshi\n");
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 165
| 2
|
#include <stdio.h>
int main() {
int h[2], k[2], a, b, c, d, l = 0, r = 0;
for (int i = 0; i < 2; i++)
scanf("%d", &h[i]);
for (int i = 0; i < 2; i++)
scanf("%d", &k[i]);
scanf("%d%d%d%d", &a, &b, &c, &d);
l = h[1] * a + (h[0] / 10) * c + h[1] * b + (h[1] / 20) * d;
for (int i = 0; i < 2; i++)
h[i] = k[i];
r = h[0] * a + (h[0] / 10) * c + h[1] * b + (h[1] / 20) * d;
if (l == r)
printf("even\n");
else if (l > r)
printf("hiroshi\n");
else
printf("kenjiro\n");
}
|
#include <stdio.h>
int main() {
int h[2], k[2], a, b, c, d, l = 0, r = 0;
for (int i = 0; i < 2; i++)
scanf("%d", &h[i]);
for (int i = 0; i < 2; i++)
scanf("%d", &k[i]);
scanf("%d%d%d%d", &a, &b, &c, &d);
l = h[0] * a + (h[0] / 10) * c + h[1] * b + (h[1] / 20) * d;
for (int i = 0; i < 2; i++)
h[i] = k[i];
r = h[0] * a + (h[0] / 10) * c + h[1] * b + (h[1] / 20) * d;
if (l == r)
printf("even\n");
else if (l > r)
printf("hiroshi\n");
else
printf("kenjiro\n");
}
|
[["-", 31, 16, 31, 16, 31, 69, 341, 342, 0, 13], ["+", 31, 16, 31, 16, 31, 69, 341, 342, 0, 13]]
| 1
| 246
| 2
|
#include <iostream>
using namespace std;
int main() {
int h[2];
int k[2];
cin >> h[0] >> h[1];
cin >> k[0] >> k[1];
int a, b, c, d;
cin >> a >> b >> c >> d;
int hp = a * h[0] + (h[0] / 10) * c + b * h[1] + (h[1] / 20) * d;
int kp = a * k[0] + (h[0] / 10) * c + b * k[1] + (k[1] / 20) * d;
if (hp > kp)
cout << "hiroshi" << endl;
else if (hp < kp)
cout << "kenjiro" << endl;
else
cout << "even" << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int h[2];
int k[2];
cin >> h[0] >> h[1];
cin >> k[0] >> k[1];
int a, b, c, d;
cin >> a >> b >> c >> d;
int hp = a * h[0] + (h[0] / 10) * c + b * h[1] + (h[1] / 20) * d;
int kp = a * k[0] + (k[0] / 10) * c + b * k[1] + (k[1] / 20) * d;
if (hp > kp)
cout << "hiroshi" << endl;
else if (hp < kp)
cout << "kenjiro" << endl;
else
cout << "even" << endl;
return 0;
}
|
[["-", 12, 16, 31, 23, 0, 16, 31, 69, 28, 22], ["+", 12, 16, 31, 23, 0, 16, 31, 69, 28, 22]]
| 1
| 186
| 2
|
#include <iostream>
using namespace std;
int main() {
int h1, h2, k1, k2, a, b, c, d;
cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
if ((h1 / 10) * c + h1 * a + (h2 / 20) * d + h2 * b >
(k1 / 10) * c + k1 * a + (k2 / 20) * d + h2 * b) {
cout << "hiroshi" << endl;
}
if ((h1 / 10) * c + h1 * a + (h2 / 20) * d + h2 * b <
(k1 / 10) * c + k1 * a + (k2 / 20) * d + h2 * b) {
cout << "kenjiro" << endl;
}
if ((h1 / 10) * c + h1 * a + (h2 / 20) * d + h2 * b ==
(k1 / 10) * c + k1 * a + (k2 / 20) * d + h2 * b) {
cout << "even" << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int h1, h2, k1, k2, a, b, c, d;
cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
if ((h1 / 10) * c + h1 * a + (h2 / 20) * d + h2 * b >
(k1 / 10) * c + k1 * a + (k2 / 20) * d + k2 * b) {
cout << "hiroshi" << endl;
}
if ((h1 / 10) * c + h1 * a + (h2 / 20) * d + h2 * b <
(k1 / 10) * c + k1 * a + (k2 / 20) * d + k2 * b) {
cout << "kenjiro" << endl;
}
if ((h1 / 10) * c + h1 * a + (h2 / 20) * d + h2 * b ==
(k1 / 10) * c + k1 * a + (k2 / 20) * d + k2 * b) {
cout << "even" << endl;
}
return 0;
}
|
[["-", 15, 339, 51, 16, 12, 16, 12, 16, 31, 22], ["+", 15, 339, 51, 16, 12, 16, 12, 16, 31, 22]]
| 1
| 230
| 6
|
#include <iostream>
using namespace std;
int main() {
int h[2], k[2];
int iwana, yamame, iwapo, yamapo;
int hiroshi, kenji;
cin >> h[0] >> h[1] >> k[0] >> k[1] >> iwana >> yamame >> iwapo >> yamapo;
hiroshi = (h[0] * iwana) + (h[1] * yamame);
kenji = (k[0] * iwana) + (k[1] * yamame);
hiroshi += ((h[0] % 10) * iwapo) + ((h[1] % 20) * yamapo);
kenji += ((k[0] % 10) * iwapo) + ((k[1] % 20) * yamapo);
if (kenji > hiroshi) {
cout << "kenjiro" << endl;
} else if (hiroshi > kenji) {
cout << "hiroshi" << endl;
} else {
cout << "even" << endl;
}
}
|
#include <iostream>
using namespace std;
int main() {
int h[2], k[2];
int iwana, yamame, iwapo, yamapo;
int hiroshi, kenji;
cin >> h[0] >> h[1] >> k[0] >> k[1] >> iwana >> yamame >> iwapo >> yamapo;
hiroshi = (h[0] * iwana) + (h[1] * yamame);
kenji = (k[0] * iwana) + (k[1] * yamame);
hiroshi += ((h[0] / 10) * iwapo) + ((h[1] / 20) * yamapo);
kenji += ((k[0] / 10) * iwapo) + ((k[1] / 20) * yamapo);
if (kenji > hiroshi) {
cout << "kenjiro" << endl;
} else if (hiroshi > kenji) {
cout << "hiroshi" << endl;
} else {
cout << "even" << endl;
}
}
|
[["-", 31, 23, 0, 16, 31, 23, 0, 16, 17, 109], ["+", 31, 23, 0, 16, 31, 23, 0, 16, 17, 85], ["-", 12, 23, 0, 16, 31, 23, 0, 16, 17, 109], ["+", 12, 23, 0, 16, 31, 23, 0, 16, 17, 85]]
| 1
| 207
| 8
|
#include <cstdio>
int main() {
int a[8];
for (int i = 0; i < 8; i++) {
scanf("%d", &a[i]);
}
int h, k;
h = a[0] * a[4] + a[0] / 10 * a[6] + a[1] * a[5] + a[1] / 10 * a[7];
k = a[2] * a[4] + a[2] / 10 * a[6] + a[3] * a[5] + a[3] / 10 * a[7];
printf("%s\n", h == k ? "even" : h > k ? "hiroshi" : "kenji");
return 0;
}
|
#include <cstdio>
int main() {
int a[8];
for (int i = 0; i < 8; i++) {
scanf("%d", &a[i]);
}
int h, k;
h = a[0] * a[4] + a[0] / 10 * a[6] + a[1] * a[5] + a[1] / 20 * a[7];
k = a[2] * a[4] + a[2] / 10 * a[6] + a[3] * a[5] + a[3] / 20 * a[7];
printf("%s\n", h == k ? "even" : h > k ? "hiroshi" : "kenjiro");
return 0;
}
|
[["-", 0, 11, 12, 16, 12, 16, 31, 16, 12, 13], ["+", 0, 11, 12, 16, 12, 16, 31, 16, 12, 13], ["-", 3, 4, 0, 41, 75, 41, 75, 5, 0, 6], ["+", 3, 4, 0, 41, 75, 41, 75, 5, 0, 6]]
| 1
| 171
| 6
|
#include <iostream>
using namespace std;
int main() {
int h, j;
int k, l;
int a, b, c, d;
cin >> h >> j >> k >> l >> a >> b >> c >> d;
int H = h * a + j * b + 10 * (h / 10) + 20 * (j / 20);
int K = k * a + l * b + 10 * (k / 10) + 20 * (l / 20);
if (H > K)
cout << "hiroshi" << endl;
if (H < K)
cout << "kenji" << endl;
if (H == K)
cout << "even" << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int h, j;
int k, l;
int a, b, c, d;
cin >> h >> j >> k >> l >> a >> b >> c >> d;
int H = h * a + j * b + c * (h / 10) + d * (j / 20);
int K = k * a + l * b + c * (k / 10) + d * (l / 20);
if (H > K)
cout << "hiroshi" << endl;
if (H < K)
cout << "kenjiro" << endl;
if (H == K)
cout << "even" << endl;
return 0;
}
|
[["-", 49, 50, 51, 16, 31, 16, 12, 16, 31, 13], ["+", 49, 50, 51, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 43, 49, 50, 51, 16, 12, 16, 31, 13], ["+", 0, 43, 49, 50, 51, 16, 12, 16, 31, 22], ["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 148
| 10
|
#include <iostream>
using namespace std;
;
int main() {
int h1, h2, k1, k2, a, b, c, d;
cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
int A = h1 / 10;
int B = h2 / 20;
int C = k1 / 10;
int D = k2 / 20;
if (h1 * a + h2 * b + A * c + B * d > k1 * a + k2 * b + C * c + D * d)
cout << "horoshi" << endl;
if (h1 * a + h2 * b + A * c + B * d < k1 * a + k2 * b + C * c + D * d)
cout << "kenjiro" << endl;
if (h1 * a + h2 * b + A * c + B * d == k1 * a + k2 * b + C * c + D * d)
cout << "even" << endl;
return 0;
}
|
#include <iostream>
using namespace std;
;
int main() {
int h1, h2, k1, k2, a, b, c, d;
cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
int A = h1 / 10;
int B = h2 / 20;
int C = k1 / 10;
int D = k2 / 20;
if (h1 * a + h2 * b + A * c + B * d > k1 * a + k2 * b + C * c + D * d)
cout << "hiroshi" << endl;
if (h1 * a + h2 * b + A * c + B * d < k1 * a + k2 * b + C * c + D * d)
cout << "kenjiro" << endl;
if (h1 * a + h2 * b + A * c + B * d == k1 * a + k2 * b + C * c + D * d)
cout << "even" << endl;
return 0;
}
|
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 205
| 2
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int h1, h2, k1, k2, sum1, sum2, a, b, c, d;
cin >> h1 >> h2;
cin >> k1 >> k2;
cin >> a >> b >> c >> d;
sum1 = h1 * a + h2 * b;
sum2 = k1 * a + k2 * b;
if (h1 == 10) {
sum1 += c;
if (h2 == 20)
sum1 += d;
}
if (k1 == 10) {
sum2 += c;
if (k2 == 20)
sum2 += d;
}
if (sum1 > sum2)
cout << "hiroshi" << endl;
else if (sum1 < sum2)
cout << "kenjiro" << endl;
else
cout << "even" << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int h1, h2, k1, k2, sum1, sum2, a, b, c, d;
cin >> h1 >> h2 >> k1 >> k2;
cin >> a >> b >> c >> d;
sum1 = h1 * a + h2 * b;
sum2 = k1 * a + k2 * b;
if (h1 >= 10) {
sum1 += c;
if (h2 >= 20)
sum1 += d;
}
if (k1 >= 10) {
sum2 += c;
if (k2 >= 20)
sum2 += d;
}
if (sum1 > sum2)
cout << "hiroshi" << endl;
else if (sum1 < sum2)
cout << "kenjiro" << endl;
else
cout << "even" << endl;
return 0;
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
| 1
| 160
| 10
|
h1, h2 = gets.split.map(&:to_i)
k1, k2 = gets.split.map(&:to_i)
a, b, c, d, = gets.split.map(&:to_i)
f = -> i, y { a * i + b * y + c * (i / 10) + d * (y / 20) }
h = f[h1, h2]
k = f[k1, k2]
puts h > k ? 'hiroshi' : h < k ? 'kenjiro' : 'draw'
|
h1, h2 = gets.split.map(&:to_i)
k1, k2 = gets.split.map(&:to_i)
a, b, c, d, = gets.split.map(&:to_i)
f = -> i, y { a * i + b * y + c * (i / 10) + d * (y / 20) }
h = f[h1, h2]
k = f[k1, k2]
puts h > k ? 'hiroshi' : h < k ? 'kenjiro' : 'even'
|
[["-", 3, 4, 0, 754, 75, 754, 75, 557, 0, 6], ["+", 3, 4, 0, 754, 75, 754, 75, 557, 0, 6]]
| 4
| 111
| 2
|
h1, h2 = map(int, input().split())
k1, k2 = map(int, input().split())
a, b, c, d = map(int, input().split())
hiroshi = (a * h1) + (b * h2) + (divmod(h1, 10)[0] * c) + (divmod(h2, 20)[0] * d)
kenjiro = (a * k1) + (b * k2) + (divmod(k1, 10)[0] * c) + (divmod(k2, 20)[0] * d)
print("even" if hiroshi else ["hiroshi", "kenjiro"][hiroshi < kenjiro])
|
h1, h2 = map(int, input().split())
k1, k2 = map(int, input().split())
a, b, c, d = map(int, input().split())
hiroshi = (a * h1) + (b * h2) + (divmod(h1, 10)[0] * c) + (divmod(h2, 20)[0] * d)
kenjiro = (a * k1) + (b * k2) + (divmod(k1, 10)[0] * c) + (divmod(k2, 20)[0] * d)
print("even" if hiroshi == kenjiro else ["hiroshi", "kenjiro"][hiroshi < kenjiro])
|
[["+", 0, 652, 3, 4, 0, 41, 0, 666, 667, 60], ["+", 0, 652, 3, 4, 0, 41, 0, 666, 0, 22]]
| 5
| 157
| 2
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int D = scan.nextInt();
int L = scan.nextInt();
System.out.println(D / L);
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int D = scan.nextInt();
int L = scan.nextInt();
System.out.println(D / L + D % L);
}
}
|
[["+", 0, 1, 0, 492, 3, 4, 0, 16, 17, 72], ["+", 0, 492, 3, 4, 0, 16, 12, 16, 31, 22], ["+", 0, 492, 3, 4, 0, 16, 12, 16, 17, 109], ["+", 0, 492, 3, 4, 0, 16, 12, 16, 12, 22]]
| 3
| 64
| 4
|
#include <stdio.h>
int main(void) {
int d, l;
scanf("%d %d", &d, l);
printf("%d", d / l + d % l);
return 0;
}
|
#include <stdio.h>
int main(void) {
int d, l;
scanf("%d %d", &d, &l);
printf("%d\n", d / l + d % l);
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 44
| 2
|
#include <stdio.h>
int main(void) {
int times, dist, len;
scanf("%d,%d,", &dist, &len);
times = (dist / len) + (dist % len);
printf("%d\n", times);
return 0;
}
|
#include <stdio.h>
int main(void) {
int times, dist, len;
scanf("%d %d", &dist, &len);
times = (dist / len) + (dist % len);
printf("%d\n", times);
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 56
| 2
|
#include <stdio.h>
int main(void) {
int times, dist, len;
scanf("%d %d", &dist, &len);
times = dist / len;
times = dist % len;
printf("%d\n", times);
return 0;
}
|
#include <stdio.h>
int main(void) {
int times, dist, len;
scanf("%d %d", &dist, &len);
times = dist / len;
times += dist % len;
printf("%d\n", times);
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107]]
| 0
| 54
| 2
|
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int N, a, b, f, vis[222];
string z;
vector<int> G[222];
void rec(int pos, int c, int s) {
if (pos == s && c) {
f = 1;
return;
}
if (c)
vis[pos] = 1;
for (auto &e : G[pos]) {
if (!vis[e])
rec(e, c + 1, s);
}
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> a >> z >> b;
a--;
if (z == "lock")
G[b + 100].push_back(a);
else
G[a].push_back(b + 100);
}
for (int i = 0; i < 200; i++) {
fill(vis, vis + 200, -1);
rec(i, 0, i);
}
cout << f << endl;
return 0;
}
|
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int N, a, b, f, vis[222];
string z;
vector<int> G[222];
void rec(int pos, int c, int s) {
if (pos == s && c) {
f = 1;
return;
}
if (c)
vis[pos] = 1;
for (auto &e : G[pos]) {
if (!vis[e])
rec(e, c + 1, s);
}
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> a >> z >> b;
a--;
b--;
if (z == "lock")
G[b + 100].push_back(a);
else
G[a].push_back(b + 100);
}
for (int i = 0; i < 200; i++) {
fill(vis, vis + 200, 0);
rec(i, 0, i);
}
cout << f << endl;
return 0;
}
|
[["+", 0, 7, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 27, 17, 68], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
| 1
| 224
| 5
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define PB push_back
#define MP make_pair
typedef pair<int, int> pii;
int n;
vector<int> rods[200];
bool visited[200];
int nw;
bool chk(int pl) {
visited[pl] = true;
REP(i, rods[pl].size()) {
int k = rods[pl][i];
if (k == nw)
return true;
if (visited[k])
continue;
if (chk(k))
return true;
}
return false;
}
int main() {
scanf("%d", &n);
REP(i, n) {
int u, d;
char s[5];
scanf("%d%s%d", &u, s, &d);
u--;
d--;
if (s[0] == 'l')
rods[d + 100].PB(u);
else
rods[u].PB(d + 100);
}
return 0;
REP(i, n) {
nw = i;
fill(visited, visited + 200, false);
if (chk(nw)) {
printf("1\n");
return 0;
}
}
printf("0\n");
}
|
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define PB push_back
#define MP make_pair
typedef pair<int, int> pii;
int n;
vector<int> rods[200];
bool visited[200];
int nw;
bool chk(int pl) {
visited[pl] = true;
REP(i, rods[pl].size()) {
int k = rods[pl][i];
if (k == nw)
return true;
if (visited[k])
continue;
if (chk(k))
return true;
}
return false;
}
int main() {
scanf("%d", &n);
REP(i, n) {
int u, d;
char s[5];
scanf("%d%s%d", &u, s, &d);
u--;
d--;
if (s[0] == 'l')
rods[d + 100].PB(u);
else
rods[u].PB(d + 100);
}
REP(i, 100) {
nw = i;
fill(visited, visited + 200, false);
if (chk(nw)) {
printf("1\n");
return 0;
}
}
printf("0\n");
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13], ["-", 0, 30, 0, 14, 8, 9, 0, 37, 0, 35], ["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
| 1
| 279
| 6
|
#include <stdio.h>
struct arrow {
int origin;
int next;
};
int checkLoop(int start, struct arrow *arrows, int arrowsCount) {
int maps[200];
int i, j, k;
for (i = 0; i < 200; i++) {
maps[i] = -1;
}
maps[start] = 0;
for (i = 0; i < 200; i++) {
for (j = 0; j < 200; j++) {
if (maps[j] != i)
continue;
for (k = 0; k < arrowsCount; k++) {
if (arrows[k].origin == j) {
if (maps[arrows[k].next] != -1) {
return 1;
}
maps[arrows[k].next] = i + 1;
}
}
}
}
return 0;
}
int main(void) {
// Here your code !
int count;
int i;
struct arrow arrows[1000];
for (i = 0; i < 1000; i++) {
arrows[i].origin = -1;
}
scanf("%d", &count);
for (i = 0; i < count; i++) {
char tmp[100];
int origin, next;
scanf("%d %s %d", &origin, tmp, &next);
origin--;
next--;
next += 100;
if (tmp[0] == 'l') {
arrows[i].origin = origin;
arrows[i].next = next;
} else {
arrows[i].origin = next;
arrows[i].next = origin;
}
}
for (i = 0; i < 100; i++) {
if (checkLoop(i, arrows, 1000)) {
printf("%d\n", 1);
return 0;
}
}
printf("%d\n", 0);
return 0;
}
|
#include <stdio.h>
struct arrow {
int origin;
int next;
};
int checkLoop(int start, struct arrow *arrows, int arrowsCount) {
int maps[200];
int i, j, k;
for (i = 0; i < 200; i++) {
maps[i] = -1;
}
maps[start] = 0;
for (i = 0; i < 200; i++) {
for (j = 0; j < 200; j++) {
if (maps[j] != i)
continue;
for (k = 0; k < arrowsCount; k++) {
if (arrows[k].origin == j) {
if (maps[arrows[k].next] == 0) {
return 1;
}
maps[arrows[k].next] = i + 1;
}
}
}
}
return 0;
}
int main(void) {
// Here your code !
int count;
int i;
struct arrow arrows[1000];
for (i = 0; i < 1000; i++) {
arrows[i].origin = -1;
}
scanf("%d", &count);
for (i = 0; i < count; i++) {
char tmp[100];
int origin, next;
scanf("%d %s %d", &origin, tmp, &next);
origin--;
next--;
next += 100;
if (tmp[0] == 'l') {
arrows[i].origin = origin;
arrows[i].next = next;
} else {
arrows[i].origin = next;
arrows[i].next = origin;
}
}
for (i = 0; i < 100; i++) {
if (checkLoop(i, arrows, 1000)) {
printf("%d\n", 1);
return 0;
}
}
printf("%d\n", 0);
return 0;
}
|
[["-", 64, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
| 1
| 388
| 4
|
#include <bits/stdc++.h>
using namespace std;
int p[333][333];
int yoko[333][333];
int tate[333][333];
int dp[301][301][301];
signed main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
cin >> p[i][j];
for (int i = 0; i < n; i++) {
int sum = 0;
for (int j = 0; j < n; j++) {
sum += p[i][j];
yoko[i][j] = sum;
}
sum = 0;
for (int j = 0; j < n; j++) {
sum += p[j][i];
tate[j][i] = sum;
}
}
int INF = 100000000;
fill_n(**dp, 333 * 333 * 333, INF);
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
for (int k = n - 1; k >= 0; k--) {
dp[i][j][k] =
yoko[i][k] + yoko[j][k] + tate[j][k] - tate[i][k] - p[j][k];
if (i == j) {
dp[i][j][k] -= yoko[i][k];
dp[i][j][k] += p[j][k];
}
if (k < n - 1)
dp[i][j][k] = max(dp[i][j][k], dp[i][j][k + 1]);
// cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl;
}
}
}
int ans = -INF;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
for (int k = 0; k < n; k++) {
int sum = tate[j][k] - tate[i][k] + p[i][k];
if (k < n - 1) {
int tmp = sum;
tmp += dp[i][j][k + 1];
tmp -= (yoko[i][k] + yoko[j][k]);
if (i == j)
tmp += yoko[i][k];
sum = max(sum, tmp);
}
ans = max(ans, sum);
// cout<<i<<" "<<j<<" "<<k<<" "<<ans<<endl;
}
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int p[333][333];
int yoko[333][333];
int tate[333][333];
int dp[301][301][301];
signed main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
cin >> p[i][j];
for (int i = 0; i < n; i++) {
int sum = 0;
for (int j = 0; j < n; j++) {
sum += p[i][j];
yoko[i][j] = sum;
}
sum = 0;
for (int j = 0; j < n; j++) {
sum += p[j][i];
tate[j][i] = sum;
}
}
int INF = 100000000;
fill_n(**dp, 301 * 301 * 301, INF);
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
for (int k = n - 1; k >= 0; k--) {
dp[i][j][k] =
yoko[i][k] + yoko[j][k] + tate[j][k] - tate[i][k] - p[j][k];
if (i == j) {
dp[i][j][k] -= yoko[i][k];
dp[i][j][k] += p[j][k];
}
if (k < n - 1)
dp[i][j][k] = max(dp[i][j][k], dp[i][j][k + 1]);
// cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<endl;
}
}
}
int ans = -INF;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
for (int k = 0; k < n; k++) {
int sum = tate[j][k] - tate[i][k] + p[i][k];
if (k < n - 1) {
int tmp = sum;
tmp += dp[i][j][k + 1];
tmp -= (yoko[i][k] + yoko[j][k]);
if (i == j)
tmp += yoko[i][k];
sum = max(sum, tmp);
}
ans = max(ans, sum);
// cout<<i<<" "<<j<<" "<<k<<" "<<ans<<endl;
}
}
}
cout << ans << endl;
return 0;
}
|
[["-", 0, 2, 3, 4, 0, 16, 31, 16, 31, 13], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 31, 13], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 582
| 6
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
int n;
int grid[301][301];
int sum(int sx, int sy, int ex, int ey) {
return grid[ex][ey] - grid[ex][sy - 1] - grid[sx - 1][ey] +
grid[sx - 1][sy - 1];
}
int calc(int sx, int sy, int ex, int ey) {
return sum(sx, sy, ex, ey) - sum(sx + 1, sy + 1, ex - 1, ey - 1);
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
scanf("%d", &grid[i][j]);
grid[i][j] += grid[i - 1][j];
grid[i][j] += grid[i][j - 1];
grid[i][j] -= grid[i - 1][j - 1];
}
}
/*for (int i = 1; i <= n; i++){
for (int j = 1; j <= n; j++){
printf("%d ", grid[i][j]);
}
puts("");
}*/
int res = -INF;
for (int i = 1; i <= n; i++) {
for (int j = i + 2; j <= n; j++) {
int p = 1;
for (int k = 3; k <= n; k++) {
int s = calc(i, p, j, k);
int t = calc(i, k - 2, j, k);
if (s < t)
p = k - 2;
// printf("%d %d %d %d %d\n", i, p, j, k, calc(i, p, j, k));
res = max(res, calc(i, p, j, k));
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= min(n, i + 1); j++) {
for (int p = 1; p <= n; p++) {
for (int k = p + 1; k <= n; k++) {
res = max(res, sum(i, p, j, k));
res = max(res, sum(p, i, k, j));
}
}
}
}
printf("%d\n", res);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 28;
int n;
int grid[301][301];
int sum(int sx, int sy, int ex, int ey) {
return grid[ex][ey] - grid[ex][sy - 1] - grid[sx - 1][ey] +
grid[sx - 1][sy - 1];
}
int calc(int sx, int sy, int ex, int ey) {
return sum(sx, sy, ex, ey) - sum(sx + 1, sy + 1, ex - 1, ey - 1);
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
scanf("%d", &grid[i][j]);
grid[i][j] += grid[i - 1][j];
grid[i][j] += grid[i][j - 1];
grid[i][j] -= grid[i - 1][j - 1];
}
}
/*for (int i = 1; i <= n; i++){
for (int j = 1; j <= n; j++){
printf("%d ", grid[i][j]);
}
puts("");
}*/
int res = -INF;
for (int i = 1; i <= n; i++) {
for (int j = i + 2; j <= n; j++) {
int p = 1;
for (int k = 3; k <= n; k++) {
int s = calc(i, p, j, k);
int t = calc(i, k - 2, j, k);
if (s < t)
p = k - 2;
// printf("%d %d %d %d %d\n", i, p, j, k, calc(i, p, j, k));
res = max(res, calc(i, p, j, k));
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = i; j <= min(n, i + 1); j++) {
for (int p = 1; p <= n; p++) {
for (int k = p; k <= n; k++) {
res = max(res, sum(i, p, j, k));
res = max(res, sum(p, i, k, j));
}
}
}
}
printf("%d\n", res);
return 0;
}
|
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 22], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13]]
| 1
| 497
| 4
|
from sys import stdin
from itertools import accumulate
def solve():
file_input = stdin
N = int(file_input.readline())
G = tuple(tuple(map(int, line.split())) for line in file_input)
# accumulated rows
ar = ((0,) + tuple(accumulate(line)) for line in G)
# accumulated columns
ac = ((0,) + tuple(accumulate(line)) for line in zip(*G))
ac_1 = next(ac)
ac = tuple(zip(*ac))
ans = 0
for i, t1 in enumerate(zip(G, ar, ac, ac_1)):
G_i, ar_i, ac_i, ac_1i = t1
ar_ii = ar_i[i]
for j, t2 in enumerate(zip(G[i:], ar_i[i+1:], ac[i+1:], ac_1[i+1:])):
G_j, ar_ij, ac_j, ac_1j = t2
if ar_ij - ar_ii > ans:
ans = ar_ij - ar_ii
if i == j:
continue
col_max = ac_1j - ac_1i
for ac_jk, ac_ik, G_ik, G_jk in zip(ac_j, ac_i, G_i[1:], G_j[1:]):
col = ac_jk - ac_ik
if col_max > 0:
c_ans = col_max + col
if c_ans > ans:
ans = c_ans
else:
if col > ans:
ans = col
t_col_max = col_max + G_ik + G_jk
if t_col_max > col:
col_max = t_col_max
else:
col_max = col
print(ans)
solve()
|
from sys import stdin
from itertools import accumulate
def solve():
file_input = stdin
N = int(file_input.readline())
G = tuple(tuple(map(int, line.split())) for line in file_input)
# accumulated rows
ar = ((0,) + tuple(accumulate(line)) for line in G)
# accumulated columns
ac = ((0,) + tuple(accumulate(line)) for line in zip(*G))
ac_1 = next(ac)
ac = tuple(zip(*ac))
ans = 0
for i, t1 in enumerate(zip(G, ar, ac, ac_1)):
G_i, ar_i, ac_i, ac_1i = t1
ar_ii = ar_i[i]
for j, t2 in enumerate(zip(G[i:], ar_i[i+1:], ac[i+1:], ac_1[i+1:]), start=i):
G_j, ar_ij, ac_j, ac_1j = t2
if ar_ij - ar_ii > ans:
ans = ar_ij - ar_ii
if i == j:
continue
col_max = ac_1j - ac_1i
for ac_jk, ac_ik, G_ik, G_jk in zip(ac_j, ac_i, G_i[1:], G_j[1:]):
col = ac_jk - ac_ik
if col_max > 0:
c_ans = col_max + col
if c_ans > ans:
ans = c_ans
else:
if col > ans:
ans = col
t_col_max = col_max + G_ik + G_jk
if t_col_max > col:
col_max = t_col_max
else:
col_max = col
print(ans)
solve()
|
[["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 0, 7, 12, 652, 3, 4, 0, 653, 141, 22], ["+", 0, 7, 12, 652, 3, 4, 0, 653, 0, 32], ["+", 0, 7, 12, 652, 3, 4, 0, 653, 51, 22]]
| 5
| 308
| 39
|
#include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
cout << a << b << c << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int a, b, c;
cin >> a >> b >> c;
cout << a + b + c << endl;
return 0;
}
|
[["-", 0, 1, 0, 16, 31, 16, 31, 16, 17, 151], ["+", 0, 16, 31, 16, 12, 16, 31, 16, 17, 72], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72]]
| 1
| 40
| 4
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int p, m, c;
cin >> p >> m >> c;
cout << p * m * c << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int p, m, c;
cin >> p >> m >> c;
cout << p + m + c << endl;
}
|
[["-", 0, 16, 31, 16, 12, 16, 31, 16, 17, 48], ["+", 0, 16, 31, 16, 12, 16, 31, 16, 17, 72], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 48], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72]]
| 1
| 37
| 4
|
#include <algorithm>
#include <iostream>
using namespace std;
int n, m, c, d, a[10000], b[1440], cnt;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> c >> d;
b[c * 60 + d] = 1;
}
cin >> m;
for (int i = 0; i < m; i++) {
cin >> c >> d;
b[c * 60 + d] = 1;
}
for (int i = 0; i < 1440; i++) {
if (b[i] == 1) {
if (cnt) {
cout << ' ';
}
cnt++;
cout << i / 60 << ':';
if (i % 60 < 10) {
cout << '0';
}
cout << i % 60 << endl;
}
}
cout << endl;
return 0;
}
|
#include <algorithm>
#include <iostream>
using namespace std;
int n, m, c, d, a[10000], b[1440], cnt;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> c >> d;
b[c * 60 + d] = 1;
}
cin >> m;
for (int i = 0; i < m; i++) {
cin >> c >> d;
b[c * 60 + d] = 1;
}
for (int i = 0; i < 1440; i++) {
if (b[i] == 1) {
if (cnt) {
cout << ' ';
}
cnt++;
cout << i / 60 << ':';
if (i % 60 < 10) {
cout << '0';
}
cout << i % 60;
}
}
cout << endl;
return 0;
}
|
[["-", 0, 57, 64, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 192
| 2
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m, p, q;
vector<int> t;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> p >> q;
t.push_back(p * 60 + q);
}
cin >> m;
for (int i = 0; i < m; i++) {
cin >> p >> q;
t.push_back(p * 60 + q);
}
sort(t.begin(), t.end());
int count_ = 0;
for (int i = 1; i < t.size(); i++) {
if (t[i - 1] != t[i]) {
if (count_) {
printf(" ");
}
printf("%d:%02d", t[i - 1] / 60, t[i - 1] % 60);
count_++;
}
}
printf("%d:%02d\n", t[n + m - 1] / 60, t[n + m - 1] % 60);
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n, m, p, q;
vector<int> t;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> p >> q;
t.push_back(p * 60 + q);
}
cin >> m;
for (int i = 0; i < m; i++) {
cin >> p >> q;
t.push_back(p * 60 + q);
}
sort(t.begin(), t.end());
int count_ = 0;
for (int i = 1; i < t.size(); i++) {
if (t[i - 1] != t[i]) {
if (count_) {
printf(" ");
}
printf("%d:%02d", t[i - 1] / 60, t[i - 1] % 60);
count_++;
}
}
printf(" %d:%02d\n", t[n + m - 1] / 60, t[n + m - 1] % 60);
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 235
| 2
|
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<pair<int, int>> po;
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
int h, m;
cin >> h >> m;
po.push_back(make_pair(h, m));
}
cin >> n;
for (int i = 0; i < n; ++i) {
int h, m;
cin >> h >> m;
po.push_back(make_pair(h, m));
}
sort(po.begin(), po.end());
po.erase(unique(po.begin(), po.end()));
for (int i = 0; i < po.size(); ++i) {
printf("%d:%02d%c", po[i].first, po[i].second,
(i + 1 == po.size() ? '\n' : ' '));
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<pair<int, int>> po;
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
int h, m;
cin >> h >> m;
po.push_back(make_pair(h, m));
}
cin >> n;
for (int i = 0; i < n; ++i) {
int h, m;
cin >> h >> m;
po.push_back(make_pair(h, m));
}
sort(po.begin(), po.end());
po.erase(unique(po.begin(), po.end()), po.end());
for (int i = 0; i < po.size(); ++i) {
printf("%d:%02d%c", po[i].first, po[i].second,
(i + 1 == po.size() ? '\n' : ' '));
}
}
|
[["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 28, 22], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 17, 131], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
| 1
| 208
| 6
|
#include <iostream>
using namespace std;
int main() {
int bus[200];
int a, b, min, sec, count = 0, now = 0, x;
cin >> a;
for (int i = 0; i < a; i++) {
cin >> min >> sec;
bus[count] = min * 60 + sec;
count++;
}
cin >> b;
for (int i = 0; i < b; i++) {
cin >> min >> sec;
bus[count] = min * 60 + sec;
count++;
}
for (int s = 0; s < count; s++) {
for (int t = s + 1; t < count; t++) {
if (bus[t] > bus[s]) {
int tmp = bus[t];
bus[t] = bus[s];
bus[s] = tmp;
}
}
}
x = 24 * 60;
for (int i = 0; i < count; i++) {
if (x == bus[i]) {
} else {
if (i != 0)
cout << " ";
cout << bus[now] / 60 << ":";
if (bus[i] % 60 < 10) {
cout << 0 << bus[i] % 60;
} else {
cout << bus[i] % 60;
}
x = bus[i];
}
}
cout << endl;
}
|
#include <iostream>
using namespace std;
int main() {
int bus[200];
int a, b, min, sec, count = 0, now = 0, x;
cin >> a;
for (int i = 0; i < a; i++) {
cin >> min >> sec;
bus[count] = min * 60 + sec;
count++;
}
cin >> b;
for (int i = 0; i < b; i++) {
cin >> min >> sec;
bus[count] = min * 60 + sec;
count++;
}
for (int s = 0; s < count; s++) {
for (int t = s + 1; t < count; t++) {
if (bus[t] < bus[s]) {
int tmp = bus[t];
bus[t] = bus[s];
bus[s] = tmp;
}
}
}
x = 24 * 60;
for (int i = 0; i < count; i++) {
if (x == bus[i]) {
} else {
if (i != 0)
cout << " ";
cout << bus[i] / 60 << ":";
if (bus[i] % 60 < 10) {
cout << 0 << bus[i] % 60;
} else {
cout << bus[i] % 60;
}
x = bus[i];
}
}
cout << endl;
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 31, 16, 12, 16, 31, 69, 341, 342, 0, 22], ["+", 31, 16, 12, 16, 31, 69, 341, 342, 0, 22]]
| 1
| 298
| 4
|
#include <iostream>
using namespace std;
int main() {
int N = 0, M = 0;
cin >> N;
int h[N], m[N];
for (int i = 0; i < N; i++)
cin >> h[i] >> m[i];
cin >> M;
int k[M], g[M], all[M + N];
for (int i = 0; i < M; i++)
cin >> k[i] >> g[i];
for (int i = 0; i < M + N; i++) {
if (i < N)
all[i] = h[i] * 60 + m[i];
else
all[i] = k[i - N] * 60 + g[i - N];
}
for (int i = 0; i < M + N - 1; i++) {
for (int j = M + N - 1; j > i; j--) {
int tmp = 0;
if (all[j] < all[j - 1]) {
tmp = all[j - 1];
all[j - 1] = all[j];
all[j] = tmp;
}
}
}
for (int i = 0; i < M + N - 1; i++) {
if (all[i] == all[i + 1])
i++;
else if (i < M + N - 2) {
if (all[i] % 60 < 10)
cout << all[i] / 60 << ':' << 0 << all[i] % 60 << ' ';
else
cout << all[i] / 60 << ':' << all[i] % 60 << ' ';
}
}
if (all[M + N - 1] % 60 < 10)
cout << all[M + N - 1] / 60 << ':' << 0 << all[M + N - 1] % 60;
else
cout << all[M + N - 1] / 60 << ':' << all[M + N - 1] % 60;
cout << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int N = 0, M = 0;
cin >> N;
int h[N], m[N];
for (int i = 0; i < N; i++)
cin >> h[i] >> m[i];
cin >> M;
int k[M], g[M], all[M + N];
for (int i = 0; i < M; i++)
cin >> k[i] >> g[i];
for (int i = 0; i < M + N; i++) {
if (i < N)
all[i] = h[i] * 60 + m[i];
else
all[i] = k[i - N] * 60 + g[i - N];
}
for (int i = 0; i < M + N - 1; i++) {
for (int j = M + N - 1; j > i; j--) {
int tmp = 0;
if (all[j] < all[j - 1]) {
tmp = all[j - 1];
all[j - 1] = all[j];
all[j] = tmp;
}
}
}
for (int i = 0; i < M + N - 1; i++) {
if (all[i] == all[i + 1])
i++;
if (i < M + N - 1) {
if (all[i] % 60 < 10)
cout << all[i] / 60 << ':' << 0 << all[i] % 60 << ' ';
else
cout << all[i] / 60 << ':' << all[i] % 60 << ' ';
}
}
if (all[M + N - 1] % 60 < 10)
cout << all[M + N - 1] / 60 << ':' << 0 << all[M + N - 1] % 60;
else
cout << all[M + N - 1] / 60 << ':' << all[M + N - 1] % 60;
cout << endl;
return 0;
}
|
[["-", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
| 1
| 455
| 3
|
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
int h[101], m[101];
for (int i = 0; i < N; i++) {
cin >> h[i] >> m[i];
}
h[N] = 24;
m[N] = 0;
int M;
cin >> M;
int k[101], g[101];
for (int j = 0; j < M; j++) {
cin >> k[j] >> g[j];
}
k[M] = 24;
g[M] = 0;
for (int i = 0, j = 0; i < N || j < M;) {
if (h[i] == k[j] && m[i] == g[j]) {
cout << h[i] << ';' << m[i] / 10 << m[i] % 10;
i++;
j++;
} else if (h[i] < k[j] || (h[i] == k[j] && m[i] < g[j])) {
cout << h[i] << ';' << m[i] / 10 << m[i] % 10;
i++;
} else {
cout << k[j] << ':' << g[j] / 10 << g[j] % 10;
j++;
}
if (i == N && j == M) {
cout << endl;
} else {
cout << ' ';
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
int h[101], m[101];
for (int i = 0; i < N; i++) {
cin >> h[i] >> m[i];
}
h[N] = 24;
m[N] = 0;
int M;
cin >> M;
int k[101], g[101];
for (int j = 0; j < M; j++) {
cin >> k[j] >> g[j];
}
k[M] = 24;
g[M] = 0;
for (int i = 0, j = 0; i < N || j < M;) {
if (h[i] == k[j] && m[i] == g[j]) {
cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
i++;
j++;
} else if (h[i] < k[j] || (h[i] == k[j] && m[i] < g[j])) {
cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
i++;
} else {
cout << k[j] << ':' << g[j] / 10 << g[j] % 10;
j++;
}
if (i == N && j == M) {
cout << endl;
} else {
cout << ' ';
}
}
return 0;
}
|
[["-", 0, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 125]]
| 1
| 333
| 4
|
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
int n, m;
vector<int> times;
cin >> n;
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
times.push_back(x * 60 + y);
}
cin >> m;
n += m;
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
times.push_back(x * 60 + y);
}
sort(times.begin(), times.end());
for (int i = 0; i < times.size(); i++) {
if (times[i] == times[i - 1])
continue;
if (i != 0)
cout << " ";
printf("%d:%02d", times[i] / 60, times[i] % 60);
}
cout << endl;
}
|
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main() {
int n, m;
vector<int> times;
cin >> n;
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
times.push_back(x * 60 + y);
}
cin >> m;
n += m;
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
times.push_back(x * 60 + y);
}
sort(times.begin(), times.end());
for (int i = 0; i < times.size(); i++) {
if (i != 0 && times[i] == times[i - 1])
continue;
if (i != 0)
cout << " ";
printf("%d:%02d", times[i] / 60, times[i] % 60);
}
cout << endl;
}
|
[["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 98]]
| 1
| 205
| 4
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int N = 0; //?£?????±±??????????????°
int h[100], m[100];
int M = 0; //?¶´??¶?????????????????°
int k[100], g[100];
vector<int> L;
void timetable() {
for (int i = 0; i < N; i++) {
L.push_back(60 * h[i] + m[i]);
}
for (int i = N; i < N + M; i++) {
L.push_back(60 * k[i - N] + g[i - N]);
}
sort(L.begin(), L.end());
L.erase(unique(L.begin(), L.end()), L.end());
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> h[i] >> m[i];
}
cin >> M;
for (int i = 0; i < M; i++) {
cin >> k[i] >> g[i];
}
timetable();
for (int i = 0; i < L.size(); i++) {
if (L[i] % 60 < 10) {
cout << L[i] / 60 << ':' << '0' << L[i] % 60;
} else {
cout << L[i] / 60 << ':' << L[i] % 60;
}
if (i < L.size() - 1) {
cout << "unchi";
}
}
cout << endl;
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int N = 0; //?£?????±±??????????????°
int h[100], m[100];
int M = 0; //?¶´??¶?????????????????°
int k[100], g[100];
vector<int> L;
void timetable() {
for (int i = 0; i < N; i++) {
L.push_back(60 * h[i] + m[i]);
}
for (int i = N; i < N + M; i++) {
L.push_back(60 * k[i - N] + g[i - N]);
}
sort(L.begin(), L.end());
L.erase(unique(L.begin(), L.end()), L.end());
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
cin >> h[i] >> m[i];
}
cin >> M;
for (int i = 0; i < M; i++) {
cin >> k[i] >> g[i];
}
timetable();
for (int i = 0; i < L.size(); i++) {
if (L[i] % 60 < 10) {
cout << L[i] / 60 << ':' << '0' << L[i] % 60;
} else {
cout << L[i] / 60 << ':' << L[i] % 60;
}
if (i < L.size() - 1) {
cout << " ";
}
}
cout << endl;
return 0;
}
|
[["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
| 1
| 350
| 2
|
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
int h[101], m[101];
for (int i = 0; i < N; i++)
cin >> h[i] >> m[i];
h[N] = 24;
m[N] = 0;
int M;
cin >> M;
int k[101], g[101];
for (int i = 0; i < M; i++)
cin >> k[i] >> g[i];
k[N] = 24;
g[N] = 0;
for (int i = 0, j = 0; i < N || j < M;) {
if (h[i] == k[j] && m[i] == g[j]) {
cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
i++;
j++;
} else if (h[i] < k[j] || (h[i] == k[j] && m[i] < g[j])) {
cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
i++;
} else {
cout << k[j] << ':' << g[j] / 10 << g[j] % 10;
j++;
}
if (i == N && j == M)
cout << endl;
else
cout << ' ';
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
int h[101], m[101];
for (int i = 0; i < N; i++)
cin >> h[i] >> m[i];
h[N] = 24;
m[N] = 0;
int M;
cin >> M;
int k[101], g[101];
for (int i = 0; i < M; i++)
cin >> k[i] >> g[i];
k[M] = 24;
g[M] = 0;
for (int i = 0, j = 0; i < N || j < M;) {
if (h[i] == k[j] && m[i] == g[j]) {
cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
i++;
j++;
} else if (h[i] < k[j] || (h[i] == k[j] && m[i] < g[j])) {
cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
i++;
} else {
cout << k[j] << ':' << g[j] / 10 << g[j] % 10;
j++;
}
if (i == N && j == M)
cout << endl;
else
cout << ' ';
}
return 0;
}
|
[["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
| 1
| 325
| 4
|
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
int h[101], m[101];
for (int i = 0; i < N; i++) {
cin >> h[i] >> m[i];
}
h[N] = 24;
m[N] = 0;
int M;
cin >> M;
int k[101], g[101];
for (int j = 0; j < M; j++) {
cin >> k[j] >> g[j];
}
k[M] = 24;
g[M] = 0;
for (int i = 0, j = 0; i < N || j < M;) {
if ((h[i] == k[j]) && (m[i] == g[j])) {
cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
i++;
j++;
} else if ((h[i] < k[j]) || ((h[i] == k[j]) && (m[i] < g[j]))) {
cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
i++;
} else {
cout << k[i] << ':' << g[j] / 10 << g[j] % 10;
j++;
}
if ((i == N) && (j == M)) {
cout << endl;
} else {
cout << ' ';
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
int h[101], m[101];
for (int i = 0; i < N; i++) {
cin >> h[i] >> m[i];
}
h[N] = 24;
m[N] = 0;
int M;
cin >> M;
int k[101], g[101];
for (int j = 0; j < M; j++) {
cin >> k[j] >> g[j];
}
k[M] = 24;
g[M] = 0;
for (int i = 0, j = 0; i < N || j < M;) {
if ((h[i] == k[j]) && (m[i] == g[j])) {
cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
i++;
j++;
} else if ((h[i] < k[j]) || ((h[i] == k[j]) && (m[i] < g[j]))) {
cout << h[i] << ':' << m[i] / 10 << m[i] % 10;
i++;
} else {
cout << k[j] << ':' << g[j] / 10 << g[j] % 10;
j++;
}
if ((i == N) && (j == M)) {
cout << endl;
} else {
cout << ' ';
}
}
return 0;
}
|
[["-", 31, 16, 31, 16, 12, 69, 341, 342, 0, 22], ["+", 31, 16, 31, 16, 12, 69, 341, 342, 0, 22]]
| 1
| 347
| 2
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define omajinai \
ios::sync_with_stdio(false); \
cin.tie(0)
// container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, b, a) for (int i = (b)-1; i >= (a); --i)
#define RREP(i, n) RFOR(i, n, 0)
// clear memory
#define CLR(a) memset((a), 0, sizeof(a))
// debug
#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
const int INF = 1e9;
const double EPS = 1e-10;
int n;
int main() {
vector<PII> v;
REP(_, 2) {
cin >> n;
REP(i, n) {
int a, b;
cin >> a >> b;
v.push_back(MP(a, b));
}
}
SORT(v);
REP(i, v.size()) {
cout << v[i].first << ":";
if (v[i].second < 10)
cout << 0;
cout << v[i].second;
if (i < v.size() - 1)
cout << " ";
}
cout << endl;
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define omajinai \
ios::sync_with_stdio(false); \
cin.tie(0)
// container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, b, a) for (int i = (b)-1; i >= (a); --i)
#define RREP(i, n) RFOR(i, n, 0)
// clear memory
#define CLR(a) memset((a), 0, sizeof(a))
// debug
#define dump(x) cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
const int INF = 1e9;
const double EPS = 1e-10;
int n;
int main() {
vector<PII> v;
REP(_, 2) {
cin >> n;
REP(i, n) {
int a, b;
cin >> a >> b;
v.push_back(MP(a, b));
}
}
SORT(v);
UNIQUE(v);
REP(i, v.size()) {
cout << v[i].first << ":";
if (v[i].second < 10)
cout << 0;
cout << v[i].second;
if (i < v.size() - 1)
cout << " ";
}
cout << endl;
}
|
[["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
| 1
| 315
| 5
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T> inline void YES(T condition) {
if (condition)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
template <class T> inline void Yes(T condition) {
if (condition)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
template <class T> inline void POSS(T condition) {
if (condition)
cout << "POSSIBLE" << endl;
else
cout << "IMPOSSIBLE" << endl;
}
template <class T> inline void Poss(T condition) {
if (condition)
cout << "Possible" << endl;
else
cout << "Impossible" << endl;
}
template <class T> inline void First(T condition) {
if (condition)
cout << "First" << endl;
else
cout << "Second" << endl;
}
int character_count(string text, char character) {
int ans = 0;
for (int i = 0; i < text.size(); i++) {
ans += (text[i] == character);
}
return ans;
}
long power(long base, long exponent, long module) {
if (exponent % 2) {
return power(base, exponent - 1, module) * base % module;
} else if (exponent) {
long root_ans = power(base, exponent / 2, module);
return root_ans * root_ans % module;
} else {
return 1;
}
}
struct position {
int y, x;
};
position move_pattern[4] = {
{-1, 0},
{0, 1},
{1, 0},
{0, -1}}; // double euclidean(position first, position second){ return
// sqrt((second.x - first.x) * (second.x - first.x) + (second.y -
// first.y) * (second.y - first.y)); }
template <class itr> void array_output(itr start, itr goal) {
string ans;
for (auto i = start; i != goal; i++) {
ans += to_string(*i) + " ";
}
ans.pop_back();
cout << ans << endl;
}
template <class itr, class func>
void nint_output(
itr start, itr goal, func out = [](itr x) { return x; }) {
string ans;
for (auto i = start; i != goal; i++) {
ans += string(out(*i)) + " ";
}
ans.pop_back();
cout << ans << endl;
}
long gcd(long a, long b) {
if (a && b) {
return gcd(min(a, b), max(a, b) % min(a, b));
} else {
return a;
}
}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)
int main() {
int N, M;
cin >> N;
vector<pair<int, string>> diagram;
for (int i = 0; i < N; i++) {
string h, m;
cin >> h >> m;
if (m.size() == 1) {
diagram.push_back({stoi(h) * 60 + stoi(m), h + ":0" + m});
} else {
diagram.push_back({stoi(h) * 60 + stoi(m), h + ":" + m});
}
}
cin >> M;
for (int i = 0; i < M; i++) {
string h, m;
cin >> h >> m;
if (m.size() == 1) {
diagram.push_back({stoi(h) * 60 + stoi(m), h + ":0" + m});
} else {
diagram.push_back({stoi(h) * 60 + stoi(m), h + ":" + m});
}
}
sort(all(diagram));
diagram.erase(unique(all(diagram)));
nint_output(all(diagram), [](auto x) { return x.second; });
}
|
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T> inline void YES(T condition) {
if (condition)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
template <class T> inline void Yes(T condition) {
if (condition)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
template <class T> inline void POSS(T condition) {
if (condition)
cout << "POSSIBLE" << endl;
else
cout << "IMPOSSIBLE" << endl;
}
template <class T> inline void Poss(T condition) {
if (condition)
cout << "Possible" << endl;
else
cout << "Impossible" << endl;
}
template <class T> inline void First(T condition) {
if (condition)
cout << "First" << endl;
else
cout << "Second" << endl;
}
int character_count(string text, char character) {
int ans = 0;
for (int i = 0; i < text.size(); i++) {
ans += (text[i] == character);
}
return ans;
}
long power(long base, long exponent, long module) {
if (exponent % 2) {
return power(base, exponent - 1, module) * base % module;
} else if (exponent) {
long root_ans = power(base, exponent / 2, module);
return root_ans * root_ans % module;
} else {
return 1;
}
}
struct position {
int y, x;
};
position move_pattern[4] = {
{-1, 0},
{0, 1},
{1, 0},
{0, -1}}; // double euclidean(position first, position second){ return
// sqrt((second.x - first.x) * (second.x - first.x) + (second.y -
// first.y) * (second.y - first.y)); }
template <class itr> void array_output(itr start, itr goal) {
string ans;
for (auto i = start; i != goal; i++) {
ans += to_string(*i) + " ";
}
ans.pop_back();
cout << ans << endl;
}
template <class itr, class func>
void nint_output(
itr start, itr goal, func out = [](itr x) { return x; }) {
string ans;
for (auto i = start; i != goal; i++) {
ans += string(out(*i)) + " ";
}
ans.pop_back();
cout << ans << endl;
}
long gcd(long a, long b) {
if (a && b) {
return gcd(min(a, b), max(a, b) % min(a, b));
} else {
return a;
}
}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)
int main() {
int N, M;
cin >> N;
vector<pair<int, string>> diagram;
for (int i = 0; i < N; i++) {
string h, m;
cin >> h >> m;
if (m.size() == 1) {
diagram.push_back({stoi(h) * 60 + stoi(m), h + ":0" + m});
} else {
diagram.push_back({stoi(h) * 60 + stoi(m), h + ":" + m});
}
}
cin >> M;
for (int i = 0; i < M; i++) {
string h, m;
cin >> h >> m;
if (m.size() == 1) {
diagram.push_back({stoi(h) * 60 + stoi(m), h + ":0" + m});
} else {
diagram.push_back({stoi(h) * 60 + stoi(m), h + ":" + m});
}
}
sort(all(diagram));
diagram.erase(unique(all(diagram)), diagram.end());
nint_output(all(diagram), [](auto x) { return x.second; });
}
|
[["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 28, 22], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 17, 131], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 24], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
| 1
| 821
| 6
|
a = list(map(int,input().split()))[1:] + list(map(int,input().split()))[1:]
a = sorted([60*a[i]+a[i+1] for i in range(0,len(a),2)])
print(" ".join("%d:%02d"%(ai/60,ai%60) for ai in a))
|
a = list(map(int,input().split()))[1:] + list(map(int,input().split()))[1:]
a = sorted(list(set([60*a[i]+a[i+1] for i in range(0,len(a),2)])))
print(" ".join("%d:%02d"%(ai/60,ai%60) for ai in a))
|
[["+", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 3, 4, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
| 5
| 102
| 6
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int N, M, p;
cin >> N >> M >> p;
int d[10020];
for (int i = 0; i < M; i++) {
cin >> d[i], d[i] -= p;
if (d[i] < 0)
d[i] += N;
}
sort(d, d + M);
int ans = 1e+9;
for (int i = 1; i < M; i++) {
ans = min(ans, d[i - 1] * 2 + N - d[i]);
ans = min(ans, (N - d[i]) * 2 - d[i - 1]);
}
ans = min(ans, N - d[0]);
ans = min(ans, d[M - 1]);
cout << ans * 100 << endl;
return 0;
}
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int N, M, p;
cin >> N >> M >> p;
int d[10020];
for (int i = 0; i < M; i++) {
cin >> d[i], d[i] -= p;
if (d[i] < 0)
d[i] += N;
}
sort(d, d + M);
int ans = 1e+9;
for (int i = 1; i < M; i++) {
ans = min(ans, d[i - 1] * 2 + N - d[i]);
ans = min(ans, (N - d[i]) * 2 + d[i - 1]);
}
ans = min(ans, N - d[0]);
ans = min(ans, d[M - 1]);
cout << ans * 100 << endl;
return 0;
}
|
[["-", 0, 11, 12, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72]]
| 1
| 198
| 2
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
int main() {
int N, M, p, flg = true;
std::cin >> N >> M >> p;
std::vector<int> d;
for (int i = 0; i < M; ++i) {
int a;
std::cin >> a;
a -= p;
if (a < 0)
a += N;
if (a == 0)
flg = false;
d.push_back(a);
}
if (flg)
d.push_back(0);
M = d.size();
std::sort(d.begin(), d.end());
int ans = 1e9;
for (int i = 0; i < M; ++i) {
// i+1 ??¨ i+2??????????????????????????????0???????§???????,??¨????????????
int bet = abs(d[0] - d[(i + 1) % N]);
int bet2 = N - abs((d[0] - d[(i + 2) % N]));
if (bet2 == N)
bet2 = 0;
if (bet > bet2)
std::swap(bet, bet2);
ans = std::min(ans, bet * 2 + bet2);
}
std::cout << ans * 100 << std::endl;
return 0;
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
int main() {
int N, M, p, flg = true;
std::cin >> N >> M >> p;
std::vector<int> d;
for (int i = 0; i < M; ++i) {
int a;
std::cin >> a;
a -= p;
if (a < 0)
a += N;
if (a == 0)
flg = false;
d.push_back(a);
}
if (flg)
d.push_back(0);
M = d.size();
std::sort(d.begin(), d.end());
int ans = 1e9;
for (int i = 0; i < M; ++i) {
// i+1 ??¨ i+2??????????????????????????????0???????§???????,??¨????????????
int bet = abs(d[0] - d[(i + 1) % M]);
int bet2 = N - abs((d[0] - d[(i + 2) % M]));
if (bet2 == N)
bet2 = 0;
if (bet > bet2)
std::swap(bet, bet2);
ans = std::min(ans, bet * 2 + bet2);
}
std::cout << ans * 100 << std::endl;
return 0;
}
|
[["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22]]
| 1
| 260
| 4
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
int main() {
int N, M, p;
std::cin >> N >> M >> p;
std::vector<int> d;
for (int i = 0; i < M; ++i) {
int a;
std::cin >> a;
a -= p;
if (a < 0)
a += N;
d.push_back(a);
}
d.push_back(0);
M = d.size();
std::sort(d.begin(), d.end());
int ans = 1e9;
for (int i = 0; i < M; ++i) {
// i+1 と i+2番目の間を通らない。0から始める,全通り試す
int bet = abs(d[0] - d[(i + 1) % N]);
int bet2 = N - abs((d[0] - d[(i + 2) % N]));
if (bet2 == N)
bet2 = 0;
if (bet > bet2)
std::swap(bet, bet2);
ans = std::min(ans, bet * 2 + bet2);
}
std::cout << ans * 100 << std::endl;
return 0;
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
int main() {
int N, M, p;
std::cin >> N >> M >> p;
std::vector<int> d;
for (int i = 0; i < M; ++i) {
int a;
std::cin >> a;
a -= p;
if (a < 0)
a += N;
d.push_back(a);
}
d.push_back(0);
M = d.size();
std::sort(d.begin(), d.end());
int ans = 1e9;
for (int i = 0; i < M; ++i) {
// i+1 ??¨ i+2??????????????????????????????0???????§???????,??¨????????????
int bet = abs(d[0] - d[(i + 1) % M]);
int bet2 = N - abs((d[0] - d[(i + 2) % M]));
if (bet2 == N)
bet2 = 0;
if (bet > bet2)
std::swap(bet, bet2);
ans = std::min(ans, bet * 2 + bet2);
}
std::cout << ans * 100 << std::endl;
return 0;
}
|
[["-", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22], ["+", 0, 16, 12, 69, 341, 342, 0, 16, 12, 22]]
| 1
| 242
| 4
|
#include <algorithm>
#include <iostream>
#include <stdio.h>
using namespace std;
int N;
int M;
int p;
int d[10010];
int ans = 0;
int main() {
cin >> N >> M >> p;
for (int i = 0; i < M; i++) {
cin >> d[i];
d[i] -= p;
if (d[i] < 0)
d[i] += N;
}
sort(&d[0], &d[M]);
ans = d[M - 1] * 100;
ans = min(ans, (N - d[0] * 100));
for (int i = 0; i < M - 1; i++) {
int c1 = 2 * (d[i] * 100);
int c2 = (N - d[i + 1] * 100);
ans = min(ans, c1 + c2);
}
for (int i = M - 1; i > 0; i--) {
int c1 = 2 * ((N - d[i]) * 100);
int c2 = (d[i - 1] * 100);
ans = min(ans, c1 + c2);
}
cout << ans << endl;
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <stdio.h>
using namespace std;
int N;
int M;
int p;
int d[10010];
int ans = 0;
int main() {
cin >> N >> M >> p;
for (int i = 0; i < M; i++) {
cin >> d[i];
d[i] -= p;
if (d[i] < 0)
d[i] += N;
}
sort(&d[0], &d[M]);
ans = d[M - 1] * 100;
ans = min(ans, ((N - d[0]) * 100));
for (int i = 0; i < M - 1; i++) {
int c1 = 2 * (d[i] * 100);
int c2 = ((N - d[i + 1]) * 100);
ans = min(ans, c1 + c2);
}
for (int i = M - 1; i > 0; i--) {
int c1 = 2 * ((N - d[i]) * 100);
int c2 = (d[i - 1] * 100);
ans = min(ans, c1 + c2);
}
cout << ans << endl;
return 0;
}
|
[["+", 3, 4, 0, 23, 0, 16, 31, 23, 0, 24], ["+", 3, 4, 0, 23, 0, 16, 31, 23, 0, 25], ["+", 8, 9, 0, 43, 49, 50, 51, 23, 0, 24], ["+", 49, 50, 51, 23, 0, 16, 31, 23, 0, 25]]
| 1
| 263
| 4
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int N, M, p;
cin >> N >> M >> p;
int d[10001];
d[0] = p;
for (int i = 1; i < M; i++) {
cin >> d[i];
}
sort(d, d + M + 1);
int c_min = N - 1;
for (int i = 0; i < M + 1; i++) {
int q = d[i];
int r1 = d[(i - 1 + M + 1) % (M + 1)];
int r2 = d[(i + 1) % (M + 1)];
int c1 = ((p - q + N) % N) * 2 + (r1 - p + N) % N;
int c2 = ((p - q + N) % N) * 2 + (p - r2 + N) % N;
c_min = min(c_min, min(c1, c2));
}
cout << c_min * 100 << endl;
return 0;
}
|
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
int N, M, p;
cin >> N >> M >> p;
int d[10001];
d[0] = p;
for (int i = 1; i <= M; i++) {
cin >> d[i];
}
sort(d, d + M + 1);
int c_min = N - 1;
for (int i = 0; i < M + 1; i++) {
int q = d[i];
int r1 = d[(i - 1 + M + 1) % (M + 1)];
int r2 = d[(i + 1) % (M + 1)];
int c1 = ((p - q + N) % N) * 2 + (r1 - p + N) % N;
int c2 = ((q - p + N) % N) * 2 + (p - r2 + N) % N;
c_min = min(c_min, min(c1, c2));
}
cout << c_min * 100 << endl;
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 31, 22], ["-", 0, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 17, 33], ["+", 0, 16, 31, 23, 0, 16, 31, 16, 12, 22]]
| 1
| 228
| 6
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int INF = 1 << 30;
int sum[1000];
int getSum(int left, int right) { // [left, right)
if (left == 0)
return sum[right - 1];
return sum[right - 1] - sum[left - 1];
}
int main() {
int N, c[1000], w[1000], dp1[1000][1001], dp2[1001];
cin >> N;
for (int i = 0; i < N; i++) {
cin >> c[i] >> w[i];
sum[i] = w[i];
if (i > 0)
sum[i] += sum[i - 1];
}
fill_n(*dp1, 1000 * 1001, false);
// dp1[left][right]: [left, right)を1人にできるか
for (int i = 0; i < N; i++) {
dp1[i][i + 1] = true;
}
for (int i = 2; i <= N; i++) { // 区間
for (int left = 0; left + i <= N; left++) { // 左
int right = left + i; // 右
if (dp1[left][right - 1]) {
int weight = getSum(left, right - 1); // 持ち上がってる
dp1[left][right] = weight <= c[right - 1];
}
if (dp1[left + 1][right]) {
int weight = getSum(left + 1, right);
dp1[left][right] = weight <= c[left];
}
}
}
fill_n(dp2, 1001, INF);
dp2[0] = 0;
for (int i = 0; i < N; i++) {
for (int j = i + 1; j <= N; j++) {
if (dp1[i][j])
dp2[j] = min(dp2[j], dp2[i] + 1);
}
}
cout << dp2[N] << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
const int INF = 1 << 30;
int sum[1000];
int getSum(int left, int right) { // [left, right)
if (left == 0)
return sum[right - 1];
return sum[right - 1] - sum[left - 1];
}
int main() {
int N, c[1000], w[1000], dp1[1000][1001], dp2[1001];
cin >> N;
for (int i = 0; i < N; i++) {
cin >> c[i] >> w[i];
sum[i] = w[i];
if (i > 0)
sum[i] += sum[i - 1];
}
fill_n(*dp1, 1000 * 1001, false);
// dp1[left][right]: [left, right)を1人にできるか
for (int i = 0; i < N; i++) {
dp1[i][i + 1] = true;
}
for (int i = 2; i <= N; i++) { // 区間
for (int left = 0; left + i <= N; left++) { // 左
int right = left + i; // 右
if (dp1[left][right - 1]) {
int weight = getSum(left, right - 1); // 持ち上がってる
dp1[left][right] |= weight <= c[right - 1];
}
if (dp1[left + 1][right]) {
int weight = getSum(left + 1, right);
dp1[left][right] |= weight <= c[left];
}
}
}
fill_n(dp2, 1001, INF);
dp2[0] = 0;
for (int i = 0; i < N; i++) {
for (int j = i + 1; j <= N; j++) {
if (dp1[i][j])
dp2[j] = min(dp2[j], dp2[i] + 1);
}
}
cout << dp2[N] << endl;
}
|
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 160]]
| 1
| 417
| 4
|
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
const int inf = 1 << 28;
int dp[1010];
bool can[1010][1010];
int w[1010], c[1010];
int main(void) {
int n;
cin >> n;
rep(i, n) cin >> c[i] >> w[i];
rep(i, n) w[i + 1] += w[i], can[i][i + 1] = true;
for (int d = 2; d <= n; ++d) {
for (int i = 0; i + d <= n; ++i) {
if (can[i + 1][i + d]) {
int cur = w[i + d - 1] - w[i];
if (c[i] >= cur)
can[i][i + d] = true;
}
if (can[i][i + d - 1]) {
int cur = w[i + d - 2];
if (i - 1 >= 0)
cur -= w[i - 1];
if (c[i] >= cur)
can[i][i + d] = true;
}
}
}
rep(i, n + 1) dp[i] = inf;
dp[0] = 0;
rep(i, n) rep(j, n) if (can[i][j + 1]) dp[j + 1] = min(dp[j + 1], dp[i] + 1);
cout << dp[n] << endl;
return 0;
}
|
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
const int inf = 1 << 28;
int dp[1010];
bool can[1010][1010];
int w[1010], c[1010];
int main(void) {
int n;
cin >> n;
rep(i, n) cin >> c[i] >> w[i];
rep(i, n) w[i + 1] += w[i], can[i][i + 1] = true;
for (int d = 2; d <= n; ++d) {
for (int i = 0; i + d <= n; ++i) {
if (can[i + 1][i + d]) {
int cur = w[i + d - 1] - w[i];
if (c[i] >= cur)
can[i][i + d] = true;
}
if (can[i][i + d - 1]) {
int cur = w[i + d - 2];
if (i - 1 >= 0)
cur -= w[i - 1];
if (c[i + d - 1] >= cur)
can[i][i + d] = true;
}
}
}
rep(i, n + 1) dp[i] = inf;
dp[0] = 0;
rep(i, n) rep(j, n) if (can[i][j + 1]) dp[j + 1] = min(dp[j + 1], dp[i] + 1);
cout << dp[n] << endl;
return 0;
}
|
[["+", 31, 69, 341, 342, 0, 16, 31, 16, 17, 72], ["+", 31, 69, 341, 342, 0, 16, 31, 16, 12, 22], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 51, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 349
| 4
|
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T> using Table = vector<vector<T>>;
const ld eps = 1e-9;
//// < "D:\D_Download\Visual Studio
///2015\Projects\programing_contest_c++\Debug\a.txt"
int memo[2010][2010];
vector<int> sums, cs, aws;
int getnum(int l, int r) {
if (memo[l][r])
return memo[l][r];
else {
if (l + 1 == r)
return 1;
else {
int amin = r - l;
for (int m = l + 1; m <= r - 1; ++m) {
const int lnum = getnum(l, m);
const int rnum = getnum(m, r);
if (m == l + 1) {
if (rnum == 1) {
if (sums[r - 1] - sums[m - 1] <= cs[l]) {
amin = 1;
}
}
} else if (m == r - 1) {
if (lnum == 1) {
if (sums[m - 1] - sums[l - 1] <= cs[r - 1]) {
amin = 1;
}
}
}
amin = min(amin, lnum + rnum);
}
return memo[l][r] = amin;
}
}
}
int main() {
int N;
cin >> N;
aws.resize(N + 1);
sums.resize(N + 1);
cs.resize(N + 1);
for (int i = 0; i < N; ++i) {
cin >> cs[i + 1];
cin >> aws[i + 1];
sums[i + 1] = sums[i] + aws[i + 1];
}
int ans = getnum(1, N + 1);
cout << ans << endl;
return 0;
}
|
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T> using Table = vector<vector<T>>;
const ld eps = 1e-9;
//// < "D:\D_Download\Visual Studio
///2015\Projects\programing_contest_c++\Debug\a.txt"
int memo[2010][2010];
vector<int> sums, cs, aws;
int getnum(int l, int r) {
if (memo[l][r])
return memo[l][r];
else {
if (l + 1 == r)
return 1;
else {
int amin = r - l;
for (int m = l + 1; m <= r - 1; ++m) {
const int lnum = getnum(l, m);
const int rnum = getnum(m, r);
if (m == l + 1) {
if (rnum == 1) {
if (sums[r - 1] - sums[m - 1] <= cs[l]) {
amin = 1;
}
}
}
if (m == r - 1) {
if (lnum == 1) {
if (sums[m - 1] - sums[l - 1] <= cs[r - 1]) {
amin = 1;
}
}
}
amin = min(amin, lnum + rnum);
}
return memo[l][r] = amin;
}
}
}
int main() {
int N;
cin >> N;
aws.resize(N + 1);
sums.resize(N + 1);
cs.resize(N + 1);
for (int i = 0; i < N; ++i) {
cin >> cs[i + 1];
cin >> aws[i + 1];
sums[i + 1] = sums[i] + aws[i + 1];
}
int ans = getnum(1, N + 1);
cout << ans << endl;
return 0;
}
|
[["-", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95]]
| 1
| 388
| 1
|
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll)a); i < ((ll)n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;
ll N, C[2000], W[2000];
ll sum[2000], memo[2000][2000];
struct edge {
ll v, dist;
};
struct state {
ll v, cost;
bool operator>(const state s) const { return cost > s.cost; }
};
vector<ll> dijkstra(vector<vector<edge>> &E, ll S) {
vector<ll> dp(E.size(), INF);
priority_queue<state, vector<state>, greater<state>> q;
q.push((state){S, 0});
while (!q.empty()) {
ll v = q.top().v, cost = q.top().cost;
q.pop();
if (dp[v] <= cost)
continue;
dp[v] = cost;
REP(i, 0, E[v].size()) {
ll nv = E[v][i].v, ncost = cost + E[v][i].dist;
if (dp[nv] > ncost)
q.push((state){nv, ncost});
}
}
return dp;
}
ll dfs(ll l, ll r) {
ll &ret = memo[l][r];
if (ret >= 0)
return ret;
if (r - l <= 1)
return ret = 1;
ret = 0;
if (dfs(l + 1, r) && (sum[r] - sum[l + 1] <= C[l]))
ret = 1;
if (dfs(l, r - 1) && (sum[r - 1] - sum[l] <= C[r - 1]))
ret = 1;
return ret;
}
int main(void) {
cin >> N;
REP(i, 0, N) cin >> C[i] >> W[i];
sum[0] = 0;
REP(i, 0, N) sum[i + 1] = sum[i] + W[i];
REP(i, 0, N) REP(j, 0, N + 1) memo[i][j] = -1;
vector<vector<edge>> E(N);
REP(i, 0, N) REP(j, i + 1, N + 1) if (dfs(i, j)) E[i].push_back((edge){j, 1});
cout << dijkstra(E, 0)[N - 1] << endl;
}
|
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll)a); i < ((ll)n); i++)
#define INF (1LL << 60)
using namespace std;
typedef long long ll;
ll N, C[2000], W[2000];
ll sum[2000], memo[2000][2000];
struct edge {
ll v, dist;
};
struct state {
ll v, cost;
bool operator>(const state s) const { return cost > s.cost; }
};
vector<ll> dijkstra(vector<vector<edge>> &E, ll S) {
vector<ll> dp(E.size(), INF);
priority_queue<state, vector<state>, greater<state>> q;
q.push((state){S, 0});
while (!q.empty()) {
ll v = q.top().v, cost = q.top().cost;
q.pop();
if (dp[v] <= cost)
continue;
dp[v] = cost;
REP(i, 0, E[v].size()) {
ll nv = E[v][i].v, ncost = cost + E[v][i].dist;
if (dp[nv] > ncost)
q.push((state){nv, ncost});
}
}
return dp;
}
ll dfs(ll l, ll r) {
ll &ret = memo[l][r];
if (ret >= 0)
return ret;
if (r - l <= 1)
return ret = 1;
ret = 0;
if (dfs(l + 1, r) && (sum[r] - sum[l + 1] <= C[l]))
ret = 1;
if (dfs(l, r - 1) && (sum[r - 1] - sum[l] <= C[r - 1]))
ret = 1;
return ret;
}
int main(void) {
cin >> N;
REP(i, 0, N) cin >> C[i] >> W[i];
sum[0] = 0;
REP(i, 0, N) sum[i + 1] = sum[i] + W[i];
REP(i, 0, N) REP(j, 0, N + 1) memo[i][j] = -1;
vector<vector<edge>> E(N + 1);
REP(i, 0, N) REP(j, i, N + 1) if (dfs(i, j)) E[i].push_back((edge){j, 1});
cout << dijkstra(E, 0)[N] << endl;
}
|
[["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 573
| 6
|
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64, i64> P;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
int n;
i64 c[1010];
i64 w[1010];
i64 sum[1010];
int dp[1010][1010];
int main() {
cin >> n;
rep(i, 0, n - 1) cin >> c[i] >> w[i];
rep(i, 1, n) { sum[i] = sum[i - 1] + w[i - 1]; }
auto getsum = [&](int l, int r) {
r--;
return sum[r] - sum[l];
};
rep(i, 0, 1000) rep(j, 0, 1000) dp[i][j] = 1e9;
rep(i, 0, 1000) dp[i][i + 1] = 1;
rep(w, 2, n) {
rep(l, 0, n - 1) {
//[l,r)
int r = l + w;
if (r > n)
continue;
rep(mid, l + 1, r - 1) {
dp[l][r] = min(dp[l][r], dp[l][mid] + dp[mid][r]);
}
// left is mighty
{
i64 w_s = getsum(l + 1, r);
if (c[l] >= w_s && dp[l + 1][r] == 1) {
dp[l][r] = 1;
}
}
{
i64 w_s = getsum(l, r - 1);
if (c[r - 1] >= w_s && dp[l][r - 1] == 1) {
dp[l][r] = 1;
}
}
/*
rep(i,0,n)
{
if(l <= i && i < r)
cout << "=";
else
cout << " ";
}
cout << dp[l][r] << endl;
*/
}
}
cout << dp[0][n] << endl;
}
|
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64, i64> P;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
int n;
i64 c[1010];
i64 w[1010];
i64 sum[1010];
int dp[1010][1010];
int main() {
cin >> n;
rep(i, 0, n - 1) cin >> c[i] >> w[i];
rep(i, 1, n) { sum[i] = sum[i - 1] + w[i - 1]; }
auto getsum = [&](int l, int r) { return sum[r] - sum[l]; };
rep(i, 0, 1000) rep(j, 0, 1000) dp[i][j] = 1e9;
rep(i, 0, 1000) dp[i][i + 1] = 1;
rep(w, 2, n) {
rep(l, 0, n - 1) {
//[l,r)
int r = l + w;
if (r > n)
continue;
rep(mid, l + 1, r - 1) {
dp[l][r] = min(dp[l][r], dp[l][mid] + dp[mid][r]);
}
// left is mighty
{
i64 w_s = getsum(l + 1, r);
if (c[l] >= w_s && dp[l + 1][r] == 1) {
dp[l][r] = 1;
}
}
{
i64 w_s = getsum(l, r - 1);
if (c[r - 1] >= w_s && dp[l][r - 1] == 1) {
dp[l][r] = 1;
}
}
/*
rep(i,0,n)
{
if(l <= i && i < r)
cout << "=";
else
cout << " ";
}
cout << dp[l][r] << endl;
*/
}
}
cout << dp[0][n] << endl;
}
|
[["-", 51, 218, 8, 9, 0, 1, 0, 27, 28, 22], ["-", 51, 218, 8, 9, 0, 1, 0, 27, 17, 68], ["-", 49, 50, 51, 218, 8, 9, 0, 1, 0, 35]]
| 1
| 421
| 3
|
n = gets.to_i
c = Array.new(n+1, 0)
w = Array.new(n+1, 0)
(1..n).each do |i|
c[i], w[i] = gets.split.map(&:to_i)
end
dp = Array.new(n+1){ Array.new(n+1, 0) }
ret = Array.new(n+1, 0)
(1..n).each do |i|
dp[i][i] = c[i]
ret[i] = ret[i-1] + 1
x = w[i]
y = w[i-1]
(i-1).downto(1) do |j|
dp[j][i] = [[dp[j+1][i], a[j] - x].min, [dp[j][i-1], a[i] - y].min].max
x += w[j]
y += w[j-1]
break if dp[j][i] < 0
ret[i] = ret[j-1] + 1
end
end
p ret[n]
|
n = gets.to_i
c = Array.new(n+1, 0)
w = Array.new(n+1, 0)
(1..n).each do |i|
c[i], w[i] = gets.split.map(&:to_i)
end
dp = Array.new(n+1){ Array.new(n+1, 0) }
ret = Array.new(n+1, 0)
(1..n).each do |i|
dp[i][i] = c[i]
ret[i] = ret[i-1] + 1
x = w[i]
y = w[i-1]
(i-1).downto(1) do |j|
dp[j][i] = [[dp[j+1][i], c[j] - x].min, [dp[j][i-1], c[i] - y].min].max
x += w[j]
y += w[j-1]
break if dp[j][i] < 0
ret[i] = ret[j-1] + 1
end
end
p ret[n]
|
[["-", 0, 652, 486, 516, 0, 738, 31, 742, 500, 22], ["+", 0, 652, 486, 516, 0, 738, 31, 742, 500, 22]]
| 4
| 256
| 4
|
import sys
f = sys.stdin
n = int(f.readline())
s = [list(map(int, line.split())) for line in f]
p = [[i==j for j in range(n + 1)] for i in range(n + 1)]
c = [0] + [c for c,w in s]
sum_w = [0] + [w for c,w in s]
for i in range(1, len(sum_w)):
sum_w[i] += sum_w[i - 1]
for length in range(n + 1):
for i in range(1, n + 1 - length):
j = i + length
if not p[i][j]:
continue
if j + 1 < n:
if sum_w[j] - sum_w[i - 1] <= c[j + 1]:
p[i][j + 1] = True
if sum_w[j] - sum_w[i - 1] <= c[i - 1]:
p[i - 1][j] = True
dp = [999999999] * (n + 1)
dp[0] = 0
for b in range(1,n + 1):
for e in range(b,n + 1):
if p[b][e]:
dp[e] = min(dp[e], dp[b - 1] + 1)
print(dp[-1])
|
import sys
f = sys.stdin
n = int(f.readline())
s = [list(map(int, line.split())) for line in f]
p = [[i==j for j in range(n + 1)] for i in range(n + 1)]
c = [0] + [c for c,w in s]
sum_w = [0] + [w for c,w in s]
for i in range(1, len(sum_w)):
sum_w[i] += sum_w[i - 1]
for length in range(n):
for i in range(1, n + 1 - length):
j = i + length
if not p[i][j]:
continue
if j + 1 <= n:
if sum_w[j] - sum_w[i - 1] <= c[j + 1]:
p[i][j + 1] = True
if sum_w[j] - sum_w[i - 1] <= c[i - 1]:
p[i - 1][j] = True
dp = [999999999] * (n + 1)
dp[0] = 0
for b in range(1,n + 1):
for e in range(1,n + 1):
if p[b][e]:
dp[e] = min(dp[e], dp[b - 1] + 1)
print(dp[-1])
|
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
| 5
| 307
| 6
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while (n-- > 0) {
int r = sc.nextInt(), t = sc.nextInt();
String a = "";
for (int y = 0; y < (t % 30 > 0 ? 2 : 1); y++)
for (int x = 0; x < (r % 100 > 0 ? 2 : 1);
x++, a += (t / 30 + y) * 5 + r / 100 + x)
if ((x | y) == 1)
a += " ";
System.out.println(a);
}
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while (n-- > 0) {
int r = sc.nextInt(), t = sc.nextInt();
String a = "";
for (int y = 0; y < (t % 30 > 0 ? 2 : 1); y++)
for (int x = 0; x < (r % 100 > 0 ? 2 : 1);
a += (t / 30 + y) * 5 + r / 100 + x++)
if ((x | y) == 1)
a += " ";
System.out.println(a);
}
}
}
|
[["-", 8, 196, 0, 7, 8, 7, 26, 27, 0, 22], ["-", 8, 196, 0, 7, 8, 7, 26, 27, 0, 29], ["-", 0, 52, 8, 196, 0, 7, 8, 7, 0, 21], ["+", 8, 7, 26, 11, 12, 16, 12, 27, 0, 29]]
| 3
| 167
| 4
|
#include <iostream>
using namespace std;
int main() {
int N, r, t;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> r >> t;
if (r % 100 == 0) {
if (t % 30 == 0) {
cout << t / 30 * 5 + r / 100;
} else {
cout << t / 30 * 5 + r / 100 << " " << (t / 30 + 1) * 5 + r / 100
<< endl;
}
} else {
if (t % 30 == 0) {
cout << t / 30 * 5 + r / 100 << " " << t / 30 * 5 + r / 100 + 1 << endl;
} else {
cout << t / 30 * 5 + r / 100 << " " << t / 30 * 5 + r / 100 + 1 << " "
<< (t / 30 + 1) * 5 + r / 100 << " "
<< (t / 30 + 1) * 5 + r / 100 + 1 << endl;
}
}
}
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int N, r, t;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> r >> t;
if (r % 100 == 0) {
if (t % 30 == 0) {
cout << t / 30 * 5 + r / 100 << endl;
} else {
cout << t / 30 * 5 + r / 100 << " " << (t / 30 + 1) * 5 + r / 100
<< endl;
}
} else {
if (t % 30 == 0) {
cout << t / 30 * 5 + r / 100 << " " << t / 30 * 5 + r / 100 + 1 << endl;
} else {
cout << t / 30 * 5 + r / 100 << " " << t / 30 * 5 + r / 100 + 1 << " "
<< (t / 30 + 1) * 5 + r / 100 << " "
<< (t / 30 + 1) * 5 + r / 100 + 1 << endl;
}
}
}
return 0;
}
|
[["+", 0, 57, 64, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 229
| 2
|
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
int main(void) {
int n, i, j;
scanf("%d", &n);
rep(i, n) {
int r, r1, d, d1;
scanf("%d%d", &r, &d);
r1 = r % 30;
r /= 30;
r *= 5;
d1 = d % 100;
d1 /= 100;
if (r1 && d1)
printf("%d %d %d %d\n", r + d, r + d + 1, r + d + 5, r + d + 6);
else if (r1 && !d1)
printf("%d %d\n", r + d, r + d + 1);
else if (!r1 && d1)
printf("%d %d\n", r + d, r + 5 + d);
else
printf("%d\n", r + d);
}
return 0;
}
|
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
int main(void) {
int n, i, j;
scanf("%d", &n);
rep(i, n) {
int r, r1, d, d1;
scanf("%d%d", &d, &r);
r1 = r % 30;
r /= 30;
r *= 5;
d1 = d % 100;
d /= 100;
if (r1 && d1)
printf("%d %d %d %d\n", r + d, r + d + 1, r + d + 5, r + d + 6);
else if (r1 && !d1)
printf("%d %d\n", r + d, r + d + 5);
else if (!r1 && d1)
printf("%d %d\n", r + d, r + 1 + d);
else
printf("%d\n", r + d);
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 66, 28, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 64, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 64, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 2, 3, 4, 0, 16, 31, 16, 12, 13], ["+", 0, 2, 3, 4, 0, 16, 31, 16, 12, 13]]
| 1
| 192
| 10
|
import java.util.Scanner;
// 0306
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), a[] = new int[4], i = 0;
while (n > 0) {
a[i++] = (n + 1) % 3 - 1;
n = (n - a[i - 1]) / 3;
}
while (i-- > 0)
System.out.print((a[i] == 0 ? "0"
: a[i] > 0 ? "+"
: "-") +
(i == 0 ? "\n" : ""));
}
}
|
import java.util.Scanner;
// 0306
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(), a[] = new int[15], i = 0;
while (n > 0) {
a[i++] = (n + 1) % 3 - 1;
n = (n - a[i - 1]) / 3;
}
while (i-- > 0)
System.out.print((a[i] == 0 ? "0"
: a[i] > 0 ? "+"
: "-") +
(i == 0 ? "\n" : ""));
}
}
|
[["-", 0, 503, 49, 200, 51, 227, 497, 505, 0, 499], ["+", 0, 503, 49, 200, 51, 227, 497, 505, 0, 499]]
| 3
| 152
| 2
|
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int w;
char d[20];
cin >> w;
for (int i = 0; i < 20; i++)
d[i] = 'a';
while (1) {
bool flag = false;
int count = 0;
for (int i = 0; i < 20; i++) {
char ans;
count += pow(3, i);
if (abs(w) <= count) {
if (w > 0) {
w -= pow(3, i);
ans = '+';
} else if (w < 0) {
w += pow(3, i);
ans = '-';
} else if (w == 0) {
flag = true;
}
for (int j = 0; j <= i; j++) {
d[i] = '0';
}
d[i] = ans;
break;
}
}
if (flag)
break;
}
bool f = false;
for (int i = 19; i >= 0; i--) {
if (d[i] != 'a')
f = true;
if (f) {
if (d[i] != 'a')
cout << d[i];
else
cout << '0';
}
}
cout << endl;
return 0;
}
|
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int w;
char d[20];
cin >> w;
for (int i = 0; i < 20; i++)
d[i] = 'a';
while (1) {
bool flag = false;
int count = 0;
for (int i = 0; i < 20; i++) {
char ans;
count += pow(3, i);
if (abs(w) <= count) {
if (w > 0) {
w -= pow(3, i);
ans = '+';
} else if (w < 0) {
w += pow(3, i);
ans = '-';
}
if (w == 0) {
flag = true;
}
for (int j = 0; j <= i; j++) {
d[i] = '0';
}
d[i] = ans;
break;
}
}
if (flag)
break;
}
bool f = false;
for (int i = 19; i >= 0; i--) {
if (d[i] != 'a')
f = true;
if (f) {
if (d[i] != 'a')
cout << d[i];
else
cout << '0';
}
}
cout << endl;
return 0;
}
|
[["-", 0, 57, 75, 76, 0, 57, 75, 76, 0, 95]]
| 1
| 279
| 1
|
#include <cmath>
#include <iostream>
using namespace std;
int n;
int v[15];
int sum;
char T[4] = "-0+";
int main() {
cin >> n;
for (int i = 0; i < 531441; i++) {
for (int j = 0; j < 12; j++) {
v[j] = (i / (int)(pow(3, j))) % 3;
sum += (v[j] - 1) * (int)(pow(3, j));
}
bool ok = false;
if (sum == n) {
for (int j = 11; j >= 0; j--) {
if (v[j] >= 2) {
ok = true;
}
if (ok == true) {
cout << T[v[j]];
}
}
}
}
cout << endl;
return 0;
}
|
#include <cmath>
#include <iostream>
using namespace std;
int n;
int v[15];
int sum;
char T[4] = "-0+";
int main() {
cin >> n;
for (int i = 0; i < 531441; i++) {
sum = 0;
for (int j = 0; j < 12; j++) {
v[j] = (i / (int)(pow(3, j))) % 3;
sum += (v[j] - 1) * (int)(pow(3, j));
}
bool ok = false;
if (sum == n) {
for (int j = 11; j >= 0; j--) {
if (v[j] >= 2) {
ok = true;
}
if (ok == true) {
cout << T[v[j]];
}
}
}
}
cout << endl;
return 0;
}
|
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
| 1
| 187
| 4
|
#include <stdio.h>
int w = 0;
int main() {
scanf("%d", w);
printf("%d", w * 4);
return 0;
}
|
#include <stdio.h>
int w = 0;
int main() {
scanf("%d", &w);
printf("%d\n", w * 32);
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 66, 17, 67], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
| 0
| 36
| 4
|
#include <iostream>
using namespace std;
int main() {
int w;
cin >> w;
cout << w * 4 << endl;
}
|
#include <iostream>
using namespace std;
int main() {
int w;
cin >> w;
cout << w * 32 << endl;
}
|
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 27
| 2
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int w;
cin >> w;
cout << w * 4;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int w;
cin >> w;
cout << w * 32 << endl;
return 0;
}
|
[["-", 8, 9, 0, 1, 0, 16, 12, 16, 12, 13], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]]
| 1
| 28
| 4
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1000000000;
int main(void) {
int n;
cin >> n;
cout << n * 128 << endl;
return 0;
}
// EOF
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int inf = 1000000000;
int main(void) {
int n;
cin >> n;
cout << n * 32 << endl;
return 0;
}
// EOF
|
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 61
| 2
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a;
cin >> a;
cout << a * 24 << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a;
cin >> a;
cout << a * 32 << endl;
return 0;
}
|
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 30
| 2
|
#include <iostream>
using namespace std;
struct Human {
bool a, b, c;
Human() { a = b = c = false; }
};
int main() {
int n, x, y, z, tmp, count = 0;
cin >> n;
Human hu[n + 1];
cin >> x;
for (int i = 0; i < x; i++) {
cin >> tmp;
hu[tmp].a = true;
}
cin >> y;
for (int i = 0; i < y; i++) {
cin >> tmp;
hu[tmp].b = true;
}
cin >> z;
for (int i = 0; i < z; i++) {
cin >> tmp;
hu[tmp].c = true;
}
for (int i = 1; i < n; i++) {
if (!hu[i].c || (hu[i].a && !hu[i].b)) {
continue;
}
count++;
}
cout << count << endl;
return 0;
}
|
#include <iostream>
using namespace std;
struct Human {
bool a, b, c;
Human() { a = b = c = false; }
};
int main() {
int n, x, y, z, tmp, count = 0;
cin >> n;
Human hu[n + 1];
cin >> x;
for (int i = 0; i < x; i++) {
cin >> tmp;
hu[tmp].a = true;
}
cin >> y;
for (int i = 0; i < y; i++) {
cin >> tmp;
hu[tmp].b = true;
}
cin >> z;
for (int i = 0; i < z; i++) {
cin >> tmp;
hu[tmp].c = true;
}
for (int i = 1; i < n + 1; i++) {
if (!hu[i].c || (hu[i].a && !hu[i].b)) {
continue;
}
count++;
}
cout << count << endl;
return 0;
}
|
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
| 1
| 222
| 20
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int n, x, y, z, re, count = 0;
bool a[101] = {false}, b[101] = {false}, c[101] = {false};
scanf("%d%d", &n, &x);
for (int i = 0; i < x; ++i) {
scanf("%d", &re);
a[re] = true;
}
scanf("%d", &y);
for (int i = 0; i < y; ++i) {
scanf("%d", &re);
b[re] = true;
}
scanf("%d", &z);
for (int i = 0; i < z; ++i) {
scanf("%d", &re);
c[re] = true;
}
for (int i = 0; i < n; ++i) {
if ((!a[i] && c[i]) || (b[i] && c[i])) {
count++;
}
}
printf("%d\n", count);
return 0;
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int n, x, y, z, re, count = 0;
bool a[101] = {false}, b[101] = {false}, c[101] = {false};
scanf("%d%d", &n, &x);
for (int i = 0; i < x; ++i) {
scanf("%d", &re);
a[re] = true;
}
scanf("%d", &y);
for (int i = 0; i < y; ++i) {
scanf("%d", &re);
b[re] = true;
}
scanf("%d", &z);
for (int i = 0; i < z; ++i) {
scanf("%d", &re);
c[re] = true;
}
for (int i = 1; i <= n; ++i) {
if ((!a[i] && c[i]) || (b[i] && c[i])) {
count++;
}
}
printf("%d\n", count);
return 0;
}
|
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
| 1
| 252
| 4
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, a, ans = 0, data[101] = {};
scanf("%d %d", &n, &m);
for (int i = 0; i < m; i++) {
scanf("%d", &a);
data[a] = 1;
}
scanf("%d", &m);
for (int i = 0; i < m; i++) {
scanf("%d", &a);
data[a] |= 2;
}
scanf("%d", &m);
for (int i = 0; i < m; i++) {
scanf("%d", &a);
data[a] |= 4;
}
for (int i = 1; i <= n; i++) {
if (data[i] == 4 || data[i] == 5 || data[i] == 7)
ans++;
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m, a, ans = 0, data[101] = {};
scanf("%d %d", &n, &m);
for (int i = 0; i < m; i++) {
scanf("%d", &a);
data[a] = 1;
}
scanf("%d", &m);
for (int i = 0; i < m; i++) {
scanf("%d", &a);
data[a] |= 2;
}
scanf("%d", &m);
for (int i = 0; i < m; i++) {
scanf("%d", &a);
data[a] |= 4;
}
for (int i = 1; i <= n; i++) {
if (data[i] == 4 || data[i] == 6 || data[i] == 7)
ans++;
}
cout << ans << endl;
return 0;
}
|
[["-", 15, 339, 51, 16, 31, 16, 12, 16, 12, 13], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 12, 13]]
| 1
| 214
| 2
|
#include <iostream>
using namespace std;
int main() {
int n, a[101][3] = {0}, sum = 0, m, z;
cin >> n;
cin >> m;
for (int i = 0; i < m; i++) {
int k;
cin >> k;
a[k][0] = 1;
}
cin >> m;
for (int i = 0; i < m; i++) {
int k;
cin >> k;
a[k][1] = 1;
}
cin >> m;
for (int i = 0; i < m; i++) {
int k;
cin >> k;
a[k][2] = 1;
}
for (int i = 0; i < n; i++) {
if (a[i][0] != 1 && a[i][2] == 1) {
sum++;
} else if (a[i][1] == 1 && a[i][2] == 1) {
sum++;
}
}
cout << sum << '\n';
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int n, a[101][3] = {0}, sum = 0, m, z;
cin >> n;
cin >> m;
for (int i = 0; i < m; i++) {
int k;
cin >> k;
a[k - 1][0] = 1;
}
cin >> m;
for (int i = 0; i < m; i++) {
int k;
cin >> k;
a[k - 1][1] = 1;
}
cin >> m;
for (int i = 0; i < m; i++) {
int k;
cin >> k;
a[k - 1][2] = 1;
}
for (int i = 0; i < n; i++) {
if (a[i][0] != 1 && a[i][2] == 1) {
sum++;
} else if (a[i][1] == 1 && a[i][2] == 1) {
sum++;
}
}
cout << sum << '\n';
return 0;
}
|
[["+", 31, 69, 28, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 232
| 6
|
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
int main(void) {
int n, i, j, k, ans = 0;
scanf("%d", &n);
int f[n][3];
rep(i, n) rep(j, 3) f[i][j] = 0;
rep(i, 3) {
int x;
scanf("%d", &x);
rep(j, x) {
int a;
scanf("%d", &a);
f[i][a - 1] = 1;
}
}
rep(i, n) if ((!f[i][0] && f[i][2]) || (f[i][1] && f[i][2]))++ ans;
printf("%d\n", ans);
return 0;
}
|
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
int main(void) {
int n, i, j, k, ans = 0;
scanf("%d", &n);
int f[n][3];
rep(i, n) rep(j, 3) f[i][j] = 0;
rep(i, 3) {
int x;
scanf("%d", &x);
rep(j, x) {
int a;
scanf("%d", &a);
f[a - 1][i] = 1;
}
}
/*rep(i, 3) {
rep(j, n) printf("%d ", f[j][i]);
printf("\n");
}*/
rep(i, n) if ((!f[i][0] && f[i][2]) || (f[i][1] && f[i][2]))++ ans;
printf("%d\n", ans);
return 0;
}
|
[["-", 0, 11, 31, 69, 28, 69, 341, 342, 0, 22], ["-", 0, 11, 31, 69, 28, 69, 341, 342, 0, 73], ["-", 0, 1, 0, 11, 31, 69, 341, 342, 0, 70], ["+", 0, 11, 31, 69, 28, 69, 341, 342, 0, 73], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 70], ["+", 0, 1, 0, 11, 31, 69, 341, 342, 0, 22]]
| 1
| 189
| 6
|
#include <iostream>
using namespace std;
void readIds(bool (&is_grouped)[100], int counter);
int main() {
int n;
int x;
int y;
int z;
bool is_grouped_x[100] = {};
bool is_grouped_y[100] = {};
bool is_grouped_z[100] = {};
int ans = 0;
/* Read */
cin >> n;
cin >> x;
readIds(is_grouped_x, x);
cin >> y;
readIds(is_grouped_y, y);
cin >> z;
readIds(is_grouped_z, z);
/* count up */
for (int i = 0; i < n; i++) {
if ((!is_grouped_x[i] && is_grouped_z[i]) ||
(is_grouped_y[i] && is_grouped_z[i])) {
ans++;
}
}
/* display */
cout << ans << endl;
return 0;
}
void readIds(bool (&is_grouped)[100], int counter) {
for (int i = 0; i < counter; i++) {
int id;
cin >> id;
is_grouped[id] = true;
}
}
|
#include <iostream>
using namespace std;
void readIds(bool (&is_grouped)[100], int counter);
int main() {
int n;
int x;
int y;
int z;
bool is_grouped_x[100] = {};
bool is_grouped_y[100] = {};
bool is_grouped_z[100] = {};
int ans = 0;
/* Read */
cin >> n;
cin >> x;
readIds(is_grouped_x, x);
cin >> y;
readIds(is_grouped_y, y);
cin >> z;
readIds(is_grouped_z, z);
/* count up */
for (int i = 0; i < n; i++) {
if ((!is_grouped_x[i] && is_grouped_z[i]) ||
(is_grouped_y[i] && is_grouped_z[i])) {
ans++;
}
}
/* display */
cout << ans << endl;
return 0;
}
void readIds(bool (&is_grouped)[100], int counter) {
for (int i = 0; i < counter; i++) {
int id;
cin >> id;
is_grouped[id - 1] = true;
}
}
|
[["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 12, 13]]
| 1
| 216
| 2
|
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int a[n] = {};
int x;
cin >> x;
for (int i = 0; i < x; i++) {
int b;
cin >> b;
for (int j = 0; j < 100; j++) {
if (b == j) {
a[j] += 1;
}
}
}
int y;
cin >> y;
for (int i = 0; i < y; i++) {
int b;
cin >> b;
for (int j = 0; j < 100; j++) {
if (b == j) {
a[j] += 10;
}
}
}
int z;
cin >> z;
for (int i = 0; i < z; i++) {
int b;
cin >> b;
for (int j = 0; j < 100; j++) {
if (b == j) {
a[j] += 100;
}
}
}
int c = 0;
for (int i = 0; i <= n; i++) {
if (a[i] == 100 || a[i] == 110 || a[i] == 111) {
c += 1;
}
}
cout << c << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int a[n + 1] = {};
int x;
cin >> x;
for (int i = 0; i < x; i++) {
int b;
cin >> b;
for (int j = 0; j <= 100; j++) {
if (b == j) {
a[j] += 1;
}
}
}
int y;
cin >> y;
for (int i = 0; i < y; i++) {
int b;
cin >> b;
for (int j = 0; j <= 100; j++) {
if (b == j) {
a[j] += 10;
}
}
}
int z;
cin >> z;
for (int i = 0; i < z; i++) {
int b;
cin >> b;
for (int j = 0; j <= 100; j++) {
if (b == j) {
a[j] += 100;
}
}
}
int c = 0;
for (int i = 0; i <= n; i++) {
if (a[i] == 100 || a[i] == 110 || a[i] == 111) {
c += 1;
}
}
cout << c << endl;
return 0;
}
|
[["+", 0, 43, 49, 50, 49, 80, 81, 16, 17, 72], ["+", 0, 43, 49, 50, 49, 80, 81, 16, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
| 1
| 270
| 8
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, a[110], t, X, Y, Z, A = 0, B = 0, C = 0;
for (int i = 0; i < 110; i++)
a[i] = 1;
cin >> N;
cin >> X;
for (int i = 0; i < X; i++) {
cin >> t;
a[t] *= 2;
}
cin >> Y;
for (int i = 0; i < Y; i++) {
cin >> t;
a[t] *= 3;
}
cin >> Z;
for (int i = 0; i < Z; i++) {
cin >> t;
a[t] *= 5;
}
for (int i = 0; i < N; i++) {
if (a[i] % 5 == 0)
A++;
if (a[i] % 10 == 0)
B++;
if (a[i] % 30 == 0)
C++;
}
cout << A - B + C << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int N, a[110], t, X, Y, Z, A = 0, B = 0, C = 0;
for (int i = 0; i < 110; i++)
a[i] = 1;
cin >> N;
cin >> X;
for (int i = 0; i < X; i++) {
cin >> t;
a[t] *= 2;
}
cin >> Y;
for (int i = 0; i < Y; i++) {
cin >> t;
a[t] *= 3;
}
cin >> Z;
for (int i = 0; i < Z; i++) {
cin >> t;
a[t] *= 5;
}
for (int i = 1; i <= N; i++) {
if (a[i] % 5 == 0)
A++;
if (a[i] % 10 == 0)
B++;
if (a[i] % 30 == 0)
C++;
}
cout << A - B + C << endl;
return 0;
}
|
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
| 1
| 229
| 4
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int t[] = new int[a];
for (int i = 0; i < a; i++) {
t[i] = sc.nextInt();
}
for (int i = a; i > 0; i--) {
int count = 0;
for (int j = 0; j < a; j++) {
if (t[j] >= i) {
count++;
}
}
if (i <= count) {
System.out.println(count);
break;
}
}
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int t[] = new int[a];
for (int i = 0; i < a; i++) {
t[i] = sc.nextInt();
}
for (int i = a; i > 0; i--) {
int count = 0;
for (int j = 0; j < a; j++) {
if (t[j] >= i) {
count++;
}
}
if (i <= count) {
System.out.println(i);
break;
}
}
}
}
|
[["-", 64, 196, 0, 1, 0, 492, 3, 4, 0, 22], ["+", 64, 196, 0, 1, 0, 492, 3, 4, 0, 22]]
| 3
| 152
| 2
|
/*
????????? ????????°???????????°??????????????? ????????????
?????´???????????§?????§????????°???????????°???????????????????????¬??????????????¨?????????????????????
?????????????????§????????????????????????????????????????????????????????£??????????????????????????????
??????????????????????????????
???????§??????????????§£?????????????????°??¨???????????????????????????????????????????¬????????????????
?????\?????????????????????????????¢????¨???????????????¨??????????????????
???????????????????????£?§£??????????????????????????????????????\?????§???????????????????????\?????????
?????¨??????????????????????????§??????????????????????????????????????¢??¨?????????
??????
????????????????????£?§£?????????????????°??¨???????????????????????????????????????????????????????????¢
????¨??????????????????°????????????????????????
??\???
??\????????\????????¢?????§??????????????????
N
p1 p2 ??? pN
??????????????????????????£?§£?????????????????°
N(1???N???100)?????????????????????
??????????????£?§£???????????????????????? pi(1???pi???100)?????????????????????
??????
????????????????????¢???????????????????????????
*/
#include <stdio.h>
#define NUM 100
int main(void) {
int n; // ??????????????£?§£?????????????????° N(1???N???100)
int d[100]; // ??£?§£???????????????????????? pi(1???pi???100)
int i, j, w;
int t = 0;
scanf("%d ", &n);
// n ?????°?????????????????\?????????
for (i = 0; i < n; i++) {
scanf("%d ", &d[i]);
}
// ?????????????????????????????????
for (i = 0; i < n - 1; i++) {
for (j = i + 1; j < n; j++) {
if (d[i] < d[j]) {
w = d[i];
d[i] = d[j];
d[j] = w;
}
}
}
t = 0; // ??¨???????????????????????? 0
for (i = n - 1; i >= 0; i--) {
// printf( "%d:%2d\n", i, d[ i ] );
/*
* ???????????????????????????????????????????¢??????????
* ????????\???????????????????????°???????????°?????§???????????°???
* ???????????????????????°????????°??¨?????????
*/
if (d[i] > i + 1) {
t = i + 1;
break;
}
}
printf("%d\n", t);
return 0;
}
|
/*
????????? ????????°???????????°??????????????? ????????????
?????´???????????§?????§????????°???????????°???????????????????????¬??????????????¨?????????????????????
?????????????????§????????????????????????????????????????????????????????£??????????????????????????????
??????????????????????????????
???????§??????????????§£?????????????????°??¨???????????????????????????????????????????¬????????????????
?????\?????????????????????????????¢????¨???????????????¨??????????????????
???????????????????????£?§£??????????????????????????????????????\?????§???????????????????????\?????????
?????¨??????????????????????????§??????????????????????????????????????¢??¨?????????
??????
????????????????????£?§£?????????????????°??¨???????????????????????????????????????????????????????????¢
????¨??????????????????°????????????????????????
??\???
??\????????\????????¢?????§??????????????????
N
p1 p2 ??? pN
??????????????????????????£?§£?????????????????°
N(1???N???100)?????????????????????
??????????????£?§£???????????????????????? pi(1???pi???100)?????????????????????
??????
????????????????????¢???????????????????????????
*/
#include <stdio.h>
#define NUM 100
int main(void) {
int n; // ??????????????£?§£?????????????????° N(1???N???100)
int d[100]; // ??£?§£???????????????????????? pi(1???pi???100)
int i, j, w;
int t = 0;
scanf("%d ", &n);
// n ?????°?????????????????\?????????
for (i = 0; i < n; i++) {
scanf("%d ", &d[i]);
}
// ?????????????????????????????????
for (i = 0; i < n - 1; i++) {
for (j = i + 1; j < n; j++) {
if (d[i] < d[j]) {
w = d[i];
d[i] = d[j];
d[j] = w;
}
}
}
t = 0; // ??¨???????????????????????? 0
for (i = n - 1; i >= 0; i--) {
// printf( "%d:%2d\n", i, d[ i ] );
/*
* ???????????????????????????????????????????¢??????????
* ????????\???????????????????????°???????????°?????§???????????°???
* ???????????????????????°????????°??¨?????????
*/
if (d[i] >= i + 1) {
t = i + 1;
break;
}
}
printf("%d\n", t);
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20]]
| 0
| 206
| 2
|
#include <stdio.h>
int main(void) {
int n, a[101];
int cnt, max, i, j;
scanf("%d", &n);
for (i = 1; i <= n; i++)
scanf("%d", &a[i]);
max = 1;
for (i = 1; i <= n; i++) {
cnt = 0;
for (j = 1; j <= n; j++) {
if (i <= a[j])
cnt++;
}
if (cnt == i && max < cnt)
max = cnt;
}
printf("%d\n", max);
}
|
#include <stdio.h>
int main(void) {
int n, a[101];
int cnt, max, i, j;
scanf("%d", &n);
for (i = 1; i <= n; i++)
scanf("%d", &a[i]);
max = 1;
for (i = 1; i <= n; i++) {
cnt = 0;
for (j = 1; j <= n; j++) {
if (i <= a[j])
cnt++;
}
if (cnt >= i && max < i)
max = i;
}
printf("%d\n", max);
}
|
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 20], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 12, 22]]
| 1
| 136
| 6
|
#include <bits/stdc++.h>
using namespace std;
// Preprocessor loop
#define CAT_I(x, y) x##y
#define CAT(x, y) CAT_I(x, y)
#define INC0 1
#define INC1 2
#define INC2 3
#define INC3 4
#define INC4 5
#define INC5 6
#define INC6 7
#define INC7 8
#define INC8 9
#define INC(i) CAT(INC, i)
#define EMPTY(...)
#define DEF_COMMA0 _, 1 EMPTY
#define COMMA0() , 0
#define IS_EMPTY_III(f, s) s
#define IS_EMPTY_II(t) IS_EMPTY_III t
#define IS_EMPTY_I(x) IS_EMPTY_II((DEF_##x()))
#define IS_EMPTY(x, ...) IS_EMPTY_I(x COMMA0)
#define IF_0(x, y) y
#define IF_1(x, y) x
#define IF(cond, x, y) CAT(IF_, cond)(x, y)
#define FOR_EACH_I9(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I8(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I7(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I6(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I5(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I4(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I3(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I2(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I1(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I0(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I(i, F, ...) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH(F, ...) FOR_EACH_I(0, F, __VA_ARGS__)
#define IF_0(x, y) y
#define IF_1(x, y) x
#define IF(cond, x, y) CAT(IF_, cond)(x, y)
#define FOR_EACH_I9(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I8(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I7(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I6(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I5(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I4(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I3(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I2(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I1(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I0(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I(i, F, ...) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH(F, ...) FOR_EACH_I(0, F, __VA_ARGS__)
// Preprocessor loop end
// Preprocessor args counter
#define PP_NARG(...) PP_NARG_(__VA_ARGS__, PP_RSEQ_N())
#define PP_NARG_(...) PP_ARG_N(__VA_ARGS__)
#define PP_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
_15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, \
_27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, \
_39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \
_51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, \
_63, N, ...) \
N
#define PP_RSEQ_N() \
63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, \
44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, \
26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, \
8, 7, 6, 5, 4, 3, 2, 1, 0
#define IS_ONEARG(...) IS_ONEARG_(__VA_ARGS__, PP_RSEQ_ONE())
#define IS_ONEARG_(...) IS_ONEARG_N(__VA_ARGS__)
#define IS_ONEARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
#define PP_RSEQ_ONE() 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0
// Preprocessor args counter end
// alternative rep macro
#define esc_paren(...) __VA_ARGS__
#define in ,
#define rep(...) rep1(rep2, (__VA_ARGS__))
#define rep1(X, A) X A
#define rep2(i, ...) \
IF(IS_ONEARG(__VA_ARGS__), rep_len1(i, __VA_ARGS__), rep3(i, __VA_ARGS__))
#define rep_len1(i, end, ...) for (int i = 0; i < end; i++)
#define rep3(i, iter, ...) rep4(rep5, (iter, i, esc_paren __VA_ARGS__))
#define rep4(X, A) X A
#define rep5(iter, ...) iter(__VA_ARGS__)
// iterators
#define up up_iter,
#define up_iter3(i, start, end) for (int i = start; i < end; i++)
#define up_iter4(i, start, end, up) for (int i = start; i < end; i += up)
#define up_iter(...) CAT(up_iter, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
#define down down_iter,
#define down_iter2(i, end) for (int i = end - 1; i >= 0; i++)
#define down_iter3(i, start, end) for (int i = end - 1; i >= start; i--)
#define down_iter4(i, start, end, down) \
for (int i = end - 1; i >= start; i -= down)
#define down_iter(...) CAT(down_iter, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
#define viter viter_iter,
#define viter_iter(i, v) \
auto tmpitr = v.begin(); \
for (auto i = *tmpitr; tmpitr != v.end(); tmpitr++)
// short names
typedef long long ll;
typedef string str;
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define vec(x) vector<x>
ll gcd(ll a, ll b) {
while (b) {
ll tmp = a % b;
a = b;
b = tmp;
}
return a;
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) \
istringstream stream(str); \
string res; \
for (int cnt = 0; getline(stream, res, sp_word); cnt++)
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) \
for (auto i : x) \
cout << i << " "; \
cout << endl;
#define outln(x) \
for (auto i : x) \
cout << i << " " << endl;
#define vec_cpy(to, from) copy(all(to), back_inserter(from))
#define ary_cpy(to, from) memcpy(to, from, sizeof from)
#define MOD = 1000000007;
// debug macros
#define DEBUG_VAR(v) << #v << "=" << v << " "
#ifdef DEBUG
#define debug_echo(e) cout << "L" << __LINE__ << ": " << e << endl
#define debug_var(...) \
cout << "L" << __LINE__ << ": " FOR_EACH(DEBUG_VAR, __VA_ARGS__) << endl
#define debug_echo_dp1(dp, N) \
{ \
cout << "[ "; \
rep(i, N) cout << dp[i] << " "; \
cout << "]" << endl; \
}
#else
#define debug_echo(e)
#define debug_var(...)
#define debug_echo_dp1(dp, N)
#endif
// Implementation
int N;
int main() {
cin >> N;
vector<int> a(N);
rep(i in N) cin >> a[i];
sort(all(a));
int maxscore = a[N - 1];
int m = 0;
rep(cur in down(1, maxscore)) {
int count = 0;
rep(j in N) {
if (cur <= a[j])
count++;
}
if (cur <= count)
m = max(m, cur);
}
cout << m << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
// Preprocessor loop
#define CAT_I(x, y) x##y
#define CAT(x, y) CAT_I(x, y)
#define INC0 1
#define INC1 2
#define INC2 3
#define INC3 4
#define INC4 5
#define INC5 6
#define INC6 7
#define INC7 8
#define INC8 9
#define INC(i) CAT(INC, i)
#define EMPTY(...)
#define DEF_COMMA0 _, 1 EMPTY
#define COMMA0() , 0
#define IS_EMPTY_III(f, s) s
#define IS_EMPTY_II(t) IS_EMPTY_III t
#define IS_EMPTY_I(x) IS_EMPTY_II((DEF_##x()))
#define IS_EMPTY(x, ...) IS_EMPTY_I(x COMMA0)
#define IF_0(x, y) y
#define IF_1(x, y) x
#define IF(cond, x, y) CAT(IF_, cond)(x, y)
#define FOR_EACH_I9(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I8(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I7(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I6(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I5(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I4(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I3(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I2(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I1(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I0(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I(i, F, ...) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH(F, ...) FOR_EACH_I(0, F, __VA_ARGS__)
#define IF_0(x, y) y
#define IF_1(x, y) x
#define IF(cond, x, y) CAT(IF_, cond)(x, y)
#define FOR_EACH_I9(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I8(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I7(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I6(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I5(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I4(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I3(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I2(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I1(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I0(i, F, x, ...) \
F(x) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH_I(i, F, ...) \
IF(IS_EMPTY(__VA_ARGS__), EMPTY, CAT(FOR_EACH_I, i))(INC(i), F, __VA_ARGS__)
#define FOR_EACH(F, ...) FOR_EACH_I(0, F, __VA_ARGS__)
// Preprocessor loop end
// Preprocessor args counter
#define PP_NARG(...) PP_NARG_(__VA_ARGS__, PP_RSEQ_N())
#define PP_NARG_(...) PP_ARG_N(__VA_ARGS__)
#define PP_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, \
_15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, \
_27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, \
_39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \
_51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, \
_63, N, ...) \
N
#define PP_RSEQ_N() \
63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, \
44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, \
26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, \
8, 7, 6, 5, 4, 3, 2, 1, 0
#define IS_ONEARG(...) IS_ONEARG_(__VA_ARGS__, PP_RSEQ_ONE())
#define IS_ONEARG_(...) IS_ONEARG_N(__VA_ARGS__)
#define IS_ONEARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
#define PP_RSEQ_ONE() 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0
// Preprocessor args counter end
// alternative rep macro
#define esc_paren(...) __VA_ARGS__
#define in ,
#define rep(...) rep1(rep2, (__VA_ARGS__))
#define rep1(X, A) X A
#define rep2(i, ...) \
IF(IS_ONEARG(__VA_ARGS__), rep_len1(i, __VA_ARGS__), rep3(i, __VA_ARGS__))
#define rep_len1(i, end, ...) for (int i = 0; i < end; i++)
#define rep3(i, iter, ...) rep4(rep5, (iter, i, esc_paren __VA_ARGS__))
#define rep4(X, A) X A
#define rep5(iter, ...) iter(__VA_ARGS__)
// iterators
#define up up_iter,
#define up_iter3(i, start, end) for (int i = start; i < end; i++)
#define up_iter4(i, start, end, up) for (int i = start; i < end; i += up)
#define up_iter(...) CAT(up_iter, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
#define down down_iter,
#define down_iter2(i, end) for (int i = end - 1; i >= 0; i++)
#define down_iter3(i, start, end) for (int i = end - 1; i >= start; i--)
#define down_iter4(i, start, end, down) \
for (int i = end - 1; i >= start; i -= down)
#define down_iter(...) CAT(down_iter, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
#define viter viter_iter,
#define viter_iter(i, v) \
auto tmpitr = v.begin(); \
for (auto i = *tmpitr; tmpitr != v.end(); tmpitr++)
// short names
typedef long long ll;
typedef string str;
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define vec(x) vector<x>
ll gcd(ll a, ll b) {
while (b) {
ll tmp = a % b;
a = b;
b = tmp;
}
return a;
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) \
istringstream stream(str); \
string res; \
for (int cnt = 0; getline(stream, res, sp_word); cnt++)
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) \
for (auto i : x) \
cout << i << " "; \
cout << endl;
#define outln(x) \
for (auto i : x) \
cout << i << " " << endl;
#define vec_cpy(to, from) copy(all(to), back_inserter(from))
#define ary_cpy(to, from) memcpy(to, from, sizeof from)
#define MOD = 1000000007;
// debug macros
#define DEBUG_VAR(v) << #v << "=" << v << " "
#ifdef DEBUG
#define debug_echo(e) cout << "L" << __LINE__ << ": " << e << endl
#define debug_var(...) \
cout << "L" << __LINE__ << ": " FOR_EACH(DEBUG_VAR, __VA_ARGS__) << endl
#define debug_echo_dp1(dp, N) \
{ \
cout << "[ "; \
rep(i, N) cout << dp[i] << " "; \
cout << "]" << endl; \
}
#else
#define debug_echo(e)
#define debug_var(...)
#define debug_echo_dp1(dp, N)
#endif
// Implementation
int N;
int main() {
cin >> N;
vector<int> a(N);
rep(i in N) cin >> a[i];
sort(all(a));
int maxscore = a[N - 1];
int m = 0;
rep(cur in down(1, maxscore + 1)) {
int count = 0;
rep(j in N) {
if (cur <= a[j])
count++;
}
if (cur <= count)
m = max(m, cur);
}
cout << m << endl;
}
|
[["+", 0, 56, 49, 53, 54, 55, 0, 42, 0, 72], ["+", 0, 56, 49, 53, 54, 55, 0, 42, 0, 13]]
| 1
| 1,134
| 2
|
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main(void) {
int N, T = 0, ans = 0;
int p[100];
cin >> N;
for (int i = 0; i < N; i++) {
cin >> p[i];
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (p[j] >= i) {
ans++;
}
}
if (ans <= i) {
break;
}
T = i;
ans = 0;
}
cout << T << endl;
return 0;
}
|
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main(void) {
int N, T = 0, ans = 0;
int p[100];
cin >> N;
for (int i = 0; i < N; i++) {
cin >> p[i];
}
for (int i = 0; i < N + 1; i++) {
for (int j = 0; j < N; j++) {
if (p[j] >= i) {
ans++;
}
}
if (ans < i) {
break;
}
T = i;
ans = 0;
}
cout << T << endl;
return 0;
}
|
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]]
| 1
| 134
| 4
|
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int p[n];
for (int i = 0; i < n; i++) {
cin >> p[i];
}
int t = 0, score = 0;
;
while (1) {
int cnt = 0;
for (int i = 0; i < n; i++) {
if (p[i] >= t)
cnt++;
}
if (cnt >= t) {
score++;
} else {
break;
}
t++;
}
cout << score << endl;
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
int p[100];
for (int i = 0; i < n; i++) {
cin >> p[i];
}
int t = 0, score = 0;
;
while (1) {
int cnt = 0;
for (int i = 0; i < n; i++) {
if (p[i] >= t)
cnt++;
}
if (cnt >= t) {
score = t;
} else {
break;
}
t++;
}
cout << score << endl;
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]]
| 1
| 125
| 5
|
#include "bits/stdc++.h"
using namespace std;
int main() {
int cnt[101];
memset(cnt, 0, sizeof(cnt));
int N;
cin >> N;
while (N--) {
int s;
cin >> s;
cnt[s]++;
}
for (int i = 100; i > 0; i--) {
cnt[i - 1] += cnt[i];
if (cnt[i] >= i) {
cout << cnt[i] << endl;
return 0;
}
}
}
|
#include "bits/stdc++.h"
using namespace std;
int main() {
int cnt[101];
memset(cnt, 0, sizeof(cnt));
int N;
cin >> N;
while (N--) {
int s;
cin >> s;
cnt[s]++;
}
for (int i = 100; i > 0; i--) {
cnt[i - 1] += cnt[i];
if (cnt[i] >= i) {
cout << i << endl;
return 0;
}
}
}
|
[["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 70], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 73]]
| 1
| 110
| 3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, sum, ten;
cin >> n;
int p[n];
for (int i = 0; i < n; i++) {
cin >> p[i];
}
for (int i = 1; i < 100; i++) {
sum = 0;
for (int j = 0; j < n; j++) {
if (p[j] >= i) {
sum++;
}
}
if (sum >= i) {
ten = sum;
}
}
cout << ten << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, sum, ten;
cin >> n;
int p[n];
for (int i = 0; i < n; i++) {
cin >> p[i];
}
for (int i = 1; i <= 100; i++) {
sum = 0;
for (int j = 0; j < n; j++) {
if (p[j] >= i) {
sum++;
}
}
if (sum >= i) {
ten = i;
}
}
cout << ten << endl;
}
|
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]]
| 1
| 120
| 4
|
#include <stdio.h>
int main(void) {
int H, R;
scanf("%d %d", &H, &R);
if (R == H) {
printf("1\n");
} else if (R == -H) {
printf("0\n");
} else
printf("-1\n");
return 0;
}
|
#include <stdio.h>
int main(void) {
int H, R;
scanf("%d %d", &H, &R);
if (R + H > 0) {
printf("1\n");
} else if (R == -H) {
printf("0\n");
} else
printf("-1\n");
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 60], ["+", 0, 57, 15, 23, 0, 16, 31, 16, 17, 72], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
| 0
| 73
| 4
|
#include <bits/stdc++.h>
using namespace std;
#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
//-------------------------------------------------
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int h, r;
cin >> h >> r;
if (h + r < 0)
cout << -1 << endl;
else if (h - r > 0)
cout << 1 << endl;
else
cout << 0 << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
//-------------------------------------------------
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int h, r;
cin >> h >> r;
if (h + r < 0)
cout << -1 << endl;
else if (h + r == 0)
cout << 0 << endl;
else
cout << 1 << endl;
return 0;
}
|
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 72], ["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 60], ["-", 0, 57, 64, 1, 0, 16, 31, 16, 12, 13], ["+", 0, 57, 64, 1, 0, 16, 31, 16, 12, 13], ["-", 75, 76, 0, 1, 0, 16, 31, 16, 12, 13], ["+", 75, 76, 0, 1, 0, 16, 31, 16, 12, 13]]
| 1
| 161
| 8
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.