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 <iostream>
#include <string>
using namespace std;
int main() {
int a, b, c, h = 0, w = 0;
char d;
while (cin >> a >> d >> b >> d >> c) {
if (a == b)
h++;
if (a * a + b * b == c * c)
w++;
}
cout << w << " " << h << endl;
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int a, b, c, h = 0, w = 0;
char d;
while (cin >> a >> d >> b >> d >> c) {
if (a == b)
h++;
if (a * a + b * b == c * c)
w++;
}
cout << w << endl;
cout << h << endl;
return 0;
}
|
[["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22]]
| 1
| 89
| 6
|
#include <cstdio>
int main() {
int a, b, c, c1, c2;
c1 = c2 = 0;
while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
if (c * c - a * a - b * b == 0) {
c1++;
}
if (a == b) {
c2++;
}
}
printf("%d %d\n", c1, c2);
return 0;
}
|
#include <cstdio>
int main() {
int a, b, c, c1, c2;
c1 = c2 = 0;
while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
if (c * c - (a * a + b * b) == 0) {
c1++;
}
if (a == b) {
c2++;
}
}
printf("%d\n%d\n", c1, c2);
return 0;
}
|
[["+", 15, 339, 51, 16, 31, 16, 12, 23, 0, 24], ["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["+", 51, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 15, 339, 51, 16, 31, 16, 12, 23, 0, 25], ["-", 0, 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, 44]]
| 1
| 94
| 8
|
// aoj 0033
#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define vvi vector<vector<int>>
#define vi vector<int>
#define All(X) X.begin(), X.end()
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int ball[10];
bool can = false;
void search(int r, int l, int n) {
// cout << n << endl;
if (n >= 10) {
can = true;
return;
}
if (r < ball[n])
search(ball[n], l, n + 1);
if (l < ball[n])
search(r, ball[n], n + 1);
}
int main() {
int n;
cin >> n;
REP(i, n) {
REP(i, 10) cin >> ball[i];
int right = 0;
int left = 0;
can = false;
search(right, left, 0);
if (can)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
}
|
#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define vvi vector<vector<int>>
#define vi vector<int>
#define All(X) X.begin(), X.end()
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//????????????
// test?????£???wrong answer????????£??????
int ball[10];
bool can = false;
void search(int r, int l, int n) {
// cout << n << endl;
if (n >= 10) {
can = true;
return;
}
if (r < ball[n])
search(ball[n], l, n + 1);
if (l < ball[n])
search(r, ball[n], n + 1);
}
int main() {
int n;
cin >> n;
REP(i, n) {
REP(i, 10) cin >> ball[i];
int right = 0;
int left = 0;
can = false;
search(right, left, 0);
if (can)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 290
| 4
|
#include <iostream>
#include <stack>
#include <vector>
int main() {
int k;
std::cin >> k;
while (k > 0) {
std::vector<int> v(10, 0);
std::stack<int> s;
std::stack<int> s2;
int a;
for (int i = 0; i < 10; i++) {
std::cin >> v[i];
}
s.push(v[0]);
s2.push(0);
for (int i = 1; i < 10; i++) {
int x = s.top(), y = s2.top();
if (v[i] > x && v[i] > y) {
if (x >= y)
s.push(v[i]);
else
s2.push(v[i]);
} else if (v[i] > x && v[i] <= y)
s.push(v[i]);
else if (v[i] <= x && v[i] > y)
s2.push(v[i]);
else {
std::cout << "No" << std::endl;
break;
}
if (i == 9)
std::cout << "Yes" << std::endl;
}
k--;
}
return 0;
}
|
#include <iostream>
#include <stack>
#include <vector>
int main() {
int k;
std::cin >> k;
while (k > 0) {
std::vector<int> v(10, 0);
std::stack<int> s;
std::stack<int> s2;
int a;
for (int i = 0; i < 10; i++) {
std::cin >> v[i];
}
s.push(v[0]);
s2.push(0);
for (int i = 1; i < 10; i++) {
int x = s.top(), y = s2.top();
if (v[i] > x && v[i] > y) {
if (x >= y)
s.push(v[i]);
else
s2.push(v[i]);
} else if (v[i] > x && v[i] <= y)
s.push(v[i]);
else if (v[i] <= x && v[i] > y)
s2.push(v[i]);
else {
std::cout << "NO" << std::endl;
break;
}
if (i == 9)
std::cout << "YES" << std::endl;
}
k--;
}
return 0;
}
|
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 276
| 4
|
#include <iostream>
using namespace std;
int tama[10], n;
bool Haireruka(int i, int left, int right) {
if (i == 10)
return true;
if (tama[i] > left) {
if (Haireruka(i + 1, tama[i], right))
return true;
}
if (tama[i] > right) {
if (Haireruka(i + 1, left, tama[i]))
return true;
}
return false;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
for (int i = 0; i < 10; i++) {
cin >> tama[i];
}
if (Haireruka(0, 0, 0))
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
|
#include <iostream>
using namespace std;
int tama[10], n;
bool Haireruka(int i, int left, int right) {
if (i == 10)
return true;
if (tama[i] > left) {
if (Haireruka(i + 1, tama[i], right))
return true;
}
if (tama[i] > right) {
if (Haireruka(i + 1, left, tama[i]))
return true;
}
return false;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
for (int i = 0; i < 10; i++) {
cin >> tama[i];
}
if (Haireruka(0, 0, 0))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 180
| 4
|
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
bool saiki(vector<int> ball, stack<int> B, stack<int> C) {
if (ball.size() == 0)
return true;
int temp = ball.front();
bool flag1 = false, flag2 = false;
ball.erase(ball.begin());
if (temp > B.top()) {
B.push(temp);
flag1 = saiki(ball, B, C);
}
B.pop();
if (temp > C.top()) {
C.push(temp);
flag2 = saiki(ball, B, C);
}
return flag1 || flag2;
}
int main() {
int N, temp;
vector<int> ball;
stack<int> B, C;
B.push(0);
C.push(0);
cin >> N;
for (int i = 0; i < N; i++) {
for (int j = 0; j < 10; j++) {
cin >> temp;
ball.push_back(temp);
}
if (saiki(ball, B, C))
cout << "YES" << endl;
else
cout << "NO" << endl;
ball.clear();
}
return 0;
}
|
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
using namespace std;
bool saiki(vector<int> ball, stack<int> B, stack<int> C) {
if (ball.size() == 0)
return true;
int temp = ball.front();
bool flag1 = false, flag2 = false;
ball.erase(ball.begin());
if (temp > B.top()) {
B.push(temp);
flag1 = saiki(ball, B, C);
B.pop();
}
if (temp > C.top()) {
C.push(temp);
flag2 = saiki(ball, B, C);
}
return flag1 || flag2;
}
int main() {
int N, temp;
vector<int> ball;
stack<int> B, C;
B.push(0);
C.push(0);
cin >> N;
for (int i = 0; i < N; i++) {
for (int j = 0; j < 10; j++) {
cin >> temp;
ball.push_back(temp);
}
if (saiki(ball, B, C))
cout << "YES" << endl;
else
cout << "NO" << endl;
ball.clear();
}
return 0;
}
|
[["-", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46]]
| 1
| 271
| 2
|
#include <iostream>
int r = 0, l = 0;
int main() {
int n;
std::cin >> n;
for (int i = 0; i < n; ++i) {
bool f = true;
for (int j = 0; j < 10; ++j) {
int a;
std::cin >> a;
if (r < a && l < a) {
if (r <= l)
l = a;
else
r = a;
} else if (r < a)
r = a;
else if (l < a)
l = a;
else
f = false;
// std::cout<<r<<" "<<l<<" "<<f<<std::endl;
}
if (f)
std::cout << "OK" << std::endl;
else
std::cout << "NO" << std::endl;
r = 0, l = 0;
}
return 0;
}
|
#include <iostream>
int r = 0, l = 0;
int main() {
int n;
std::cin >> n;
for (int i = 0; i < n; ++i) {
bool f = true;
for (int j = 0; j < 10; ++j) {
int a;
std::cin >> a;
if (r < a && l < a) {
if (r <= l)
l = a;
else
r = a;
} else if (r < a)
r = a;
else if (l < a)
l = a;
else
f = false;
// std::cout<<r<<" "<<l<<" "<<f<<std::endl;
}
if (f)
std::cout << "YES" << std::endl;
else
std::cout << "NO" << std::endl;
r = 0, l = 0;
}
return 0;
}
|
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 167
| 2
|
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
int a[10];
vector<int> b, c;
bool dfs(int i) {
if (i == 10) {
// 判定
for (int j = 1; j < b.size() - 1; j++) {
if (b[j] < b[j - 1])
return false;
}
for (int j = 1; j < c.size() - 1; j++) {
if (c[j] < c[j - 1])
return false;
}
return true;
}
bool res = false;
b.push_back(a[i]);
res = res || dfs(i + 1);
b.pop_back();
c.push_back(a[i]);
res = res || dfs(i + 1);
c.pop_back();
return res;
}
int main() {
// ifstream ifs( "test.txt" );
int n;
cin >> n;
for (int i = 0; i < n; i++) {
// 入力
for (int j = 0; j < 10; j++) {
cin >> a[j];
}
b.clear();
c.clear();
// 計算
bool res = dfs(0);
// 出力
cout << ((res) ? "YES" : "NO") << endl;
}
}
|
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
int a[10];
vector<int> b, c;
bool dfs(int i) {
if (i == 10) {
// 判定
for (int j = 1; j < b.size(); j++) {
if (b[j] < b[j - 1])
return false;
}
for (int j = 1; j < c.size(); j++) {
if (c[j] < c[j - 1])
return false;
}
return true;
}
bool res = false;
b.push_back(a[i]);
res = res || dfs(i + 1);
b.pop_back();
c.push_back(a[i]);
res = res || dfs(i + 1);
c.pop_back();
return res;
}
int main() {
// ifstream ifs( "test.txt" );
int n;
cin >> n;
for (int i = 0; i < n; i++) {
// 入力
for (int j = 0; j < 10; j++) {
cin >> a[j];
}
b.clear();
c.clear();
// 計算
bool res = dfs(0);
// 出力
cout << ((res) ? "YES" : "NO") << endl;
}
}
|
[["-", 64, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 64, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
| 1
| 278
| 4
|
#include <iostream>
#include <stack>
using namespace std;
int func(int *ball, int n, int cur, stack<int> b, stack<int> c) {
int ball_cur = ball[cur];
int count = 0;
if (cur == n) {
return 1;
}
if (b.empty() || b.top() < ball_cur) {
b.push(ball_cur);
count += func(ball, n, cur + 1, b, c);
b.pop();
}
if (c.empty() || c.top() < ball_cur) {
c.push(ball_cur);
count += func(ball, n, cur + 1, b, c);
c.pop();
}
return count;
}
int main() {
int n;
int ball[10];
stack<int> stk_b, stk_c;
cin >> n;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < 10; ++j) {
cin >> ball[j];
}
cout << (func(ball, 10, 0, stk_b, stk_c) ? "Yes" : "No") << endl;
}
return 0;
}
|
#include <iostream>
#include <stack>
using namespace std;
int func(int *ball, int n, int cur, stack<int> b, stack<int> c) {
int ball_cur = ball[cur];
int count = 0;
if (cur == n) {
return 1;
}
if (b.empty() || b.top() < ball_cur) {
b.push(ball_cur);
count += func(ball, n, cur + 1, b, c);
b.pop();
}
if (c.empty() || c.top() < ball_cur) {
c.push(ball_cur);
count += func(ball, n, cur + 1, b, c);
c.pop();
}
return count;
}
int main() {
int n;
int ball[10];
stack<int> stk_b, stk_c;
cin >> n;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < 10; ++j) {
cin >> ball[j];
}
cout << (func(ball, 10, 0, stk_b, stk_c) ? "YES" : "NO") << endl;
}
return 0;
}
|
[["-", 31, 16, 12, 23, 0, 41, 64, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 64, 5, 0, 6], ["-", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6]]
| 1
| 254
| 4
|
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
bool flag = false;
int prev;
int in[10];
int used[10];
for (int j = 0; j < 10; j++) {
cin >> in[i];
}
prev = in[0];
vector<int> B;
vector<int> C;
for (int j = 0; j < 10; j++) {
if (prev > in[j]) {
C.push_back(in[j]);
used[j] = false;
continue;
} else {
prev = in[j];
B.push_back(in[j]);
used[j] = true;
}
}
prev = C[0];
for (int j = 0; j < C.size(); j++) {
if (prev > C[j]) {
flag = true;
} else {
prev = C[j];
}
}
if (flag)
cout << "NO" << endl;
else
cout << "YES" << endl;
}
return 0;
}
|
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
bool flag = false;
int prev;
int in[10];
int used[10];
for (int j = 0; j < 10; j++) {
cin >> in[j];
}
prev = in[0];
vector<int> B;
vector<int> C;
for (int j = 0; j < 10; j++) {
if (prev > in[j]) {
C.push_back(in[j]);
used[j] = false;
continue;
} else {
prev = in[j];
B.push_back(in[j]);
used[j] = true;
}
}
prev = C[0];
for (int j = 0; j < C.size(); j++) {
if (prev > C[j]) {
flag = true;
break;
} else {
prev = C[j];
}
}
if (flag)
cout << "NO" << endl;
else
cout << "YES" << endl;
}
return 0;
}
|
[["-", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 16, 12, 69, 341, 342, 0, 22], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94]]
| 1
| 248
| 4
|
#include <algorithm>
#include <cstdio>
using namespace std;
int N;
int l[15];
int b, c;
// int res[1000000000000];
void solve(int k) {
for (int i = 0; i < 10; i++) {
if (b < l[i] && c < l[i]) {
if (l[i] - b < l[i] - c)
b = l[i];
else
c = l[i];
} else if (b < l[i] && c > l[i])
b = l[i];
else if (b > l[i] && c < l[i])
c = l[i];
else {
// res[k]=0;
printf("NO");
return;
}
}
printf("YES");
return;
}
int main() {
scanf("%d", &N);
for (int i = 0; i < N; i++) {
b = 0;
c = 0;
scanf("%d%d%d%d%d%d%d%d%d%d", &l[0], &l[1], &l[2], &l[3], &l[4], &l[5],
&l[6], &l[7], &l[8], &l[9]);
solve(i);
}
/*for(int i=0;i<N;i++){
if(res[i]==0) printf("NO\n");
else printf("YES\n");
}
*/
return 0;
}
|
#include <algorithm>
#include <cstdio>
using namespace std;
int N;
int l[15];
int b, c;
// int res[1000000000000];
void solve(int k) {
for (int i = 0; i < 10; i++) {
if (b < l[i] && c < l[i]) {
if (l[i] - b < l[i] - c)
b = l[i];
else
c = l[i];
} else if (b < l[i] && c > l[i])
b = l[i];
else if (b > l[i] && c < l[i])
c = l[i];
else {
// res[k]=0;
printf("NO\n");
return;
}
}
printf("YES\n");
return;
}
int main() {
scanf("%d", &N);
for (int i = 0; i < N; i++) {
b = 0;
c = 0;
scanf("%d%d%d%d%d%d%d%d%d%d", &l[0], &l[1], &l[2], &l[3], &l[4], &l[5],
&l[6], &l[7], &l[8], &l[9]);
solve(i);
}
/*for(int i=0;i<N;i++){
if(res[i]==0) printf("NO\n");
else printf("YES\n");
}
*/
return 0;
}
|
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 282
| 2
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
const int MAX_M = 15;
int N, H[10];
double dp[2][(1 << MAX_M) + 1];
int solve() {
int big = 0, small = 0;
for (int i = 0; i < 10; i++) {
if (big < small)
swap(big, small);
if (H[i] < small) {
printf("No\n");
goto JUMP;
}
if (H[i] > big)
big = H[i];
else if (H[i] > small)
small = H[i];
}
printf("Yes\n");
JUMP:
return 0;
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
for (int j = 0; j < 10; j++) {
cin >> H[j];
}
solve();
}
return 0;
}
|
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
const int MAX_M = 15;
int N, H[10];
double dp[2][(1 << MAX_M) + 1];
int solve() {
int big = 0, small = 0;
for (int i = 0; i < 10; i++) {
if (big < small)
swap(big, small);
if (H[i] < small) {
printf("NO\n");
goto JUMP;
}
if (H[i] > big)
big = H[i];
else if (H[i] > small)
small = H[i];
}
printf("YES\n");
JUMP:
return 0;
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
for (int j = 0; j < 10; j++) {
cin >> H[j];
}
solve();
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 207
| 29
|
#include <algorithm>
#include <iostream>
using namespace std;
int ball[10];
bool solve(int i, int a, int b) {
if (i == 10)
return true;
bool ans = false;
if (a < ball[i])
ans = solve(i + i, ball[i], b);
if (b < ball[i])
ans = solve(i + i, a, ball[i]);
return ans;
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 10; j++) {
cin >> ball[j];
}
if (solve(0, 0, 0))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
// beatmaniaIIDX 23th copula
|
#include <algorithm>
#include <iostream>
using namespace std;
int ball[10];
bool solve(int i, int a, int b) {
if (i == 10)
return true;
bool ans = false;
if (a < ball[i])
ans = solve(i + 1, ball[i], b);
if (b < ball[i])
ans = solve(i + 1, a, ball[i]);
return ans;
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 10; j++) {
cin >> ball[j];
}
if (solve(0, 0, 0))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
// beatmaniaIIDX 23th copula
|
[["-", 0, 11, 12, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
| 1
| 179
| 4
|
// C++14 (Clang 3.8.0)
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rp(i, a, b) for (int(i) = (int)(a); i < (int)(b); ++i)
typedef long long ll;
using namespace std;
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
stack<int> a, b;
a.push(0);
b.push(0);
bool flag = true;
for (int j = 0; j < 10; j++) {
int tm;
cin >> tm;
if (tm > a.top())
a.push(tm);
else if (tm > b.top())
b.push(tm);
else {
flag = false;
}
}
if (flag)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
};
|
// C++14 (Clang 3.8.0)
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define rp(i, a, b) for (int(i) = (int)(a); i < (int)(b); ++i)
typedef long long ll;
using namespace std;
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i++) {
stack<int> a, b;
a.push(0);
b.push(0);
bool flag = true;
for (int j = 0; j < 10; j++) {
int tm;
cin >> tm;
if (tm > a.top())
a.push(tm);
else if (tm > b.top())
b.push(tm);
else {
flag = false;
}
}
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
};
|
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 206
| 4
|
// C++14 (Clang 3.8.0)
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
int in[10];
bool dfs(int n, vector<int> l, vector<int> r) {
if (n == 10)
return true;
if (l.size() == 0 or in[n] > l[l.size() - 1]) {
l.push_back(in[n]);
return dfs(n + 1, l, r);
}
if (r.size() == 0 or in[n] > r[r.size() - 1]) {
r.push_back(in[n]);
return dfs(n + 1, l, r);
}
return false;
}
int main() {
int d;
cin >> d;
for (int dd = 0; dd < d; dd++) {
for (int i = 0; i < 10; i++) {
cin >> in[i];
}
vector<int> l, r;
if (dfs(0, l, r))
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
|
// C++14 (Clang 3.8.0)
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
int in[10];
bool dfs(int n, vector<int> l, vector<int> r) {
if (n == 10)
return true;
if (l.size() == 0 or in[n] > l[l.size() - 1]) {
l.push_back(in[n]);
return dfs(n + 1, l, r);
}
if (r.size() == 0 or in[n] > r[r.size() - 1]) {
r.push_back(in[n]);
return dfs(n + 1, l, r);
}
return false;
}
int main() {
int d;
cin >> d;
for (int dd = 0; dd < d; dd++) {
for (int i = 0; i < 10; i++) {
cin >> in[i];
}
vector<int> l, r;
if (dfs(0, l, r))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 292
| 4
|
#include <stdio.h>
int ball[10];
bool can(int n, int left, int right) {
bool flag;
if (n == 10)
return true;
if (ball[n] > right && can(n + 1, left, ball[n]))
return true;
if (ball[n] > left && can(n + 1, ball[n], right))
return true;
return false;
}
int main() {
int N;
scanf("%d", &N);
for (int i = 0; i < N; i++) {
for (int j = 0; j < 10; j++) {
scanf("%d", &ball[j]);
}
printf(can(0, 0, 0) ? "YES" : "NO");
}
}
|
#include <stdio.h>
int ball[10];
bool can(int n, int left, int right) {
bool flag;
if (n == 10)
return true;
if (ball[n] > right && can(n + 1, left, ball[n]))
return true;
if (ball[n] > left && can(n + 1, ball[n], right))
return true;
return false;
}
int main() {
int N;
scanf("%d", &N);
for (int i = 0; i < N; i++) {
for (int j = 0; j < 10; j++) {
scanf("%d", &ball[j]);
}
printf(can(0, 0, 0) ? "YES\n" : "NO\n");
}
}
|
[["+", 0, 2, 3, 4, 0, 41, 64, 5, 0, 44], ["+", 0, 2, 3, 4, 0, 41, 75, 5, 0, 44]]
| 1
| 173
| 2
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define REP(i, a, b) for (int i = (a); i < int(b); i++)
#define all(x) (x).begin(), x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x % (mod))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ddx[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
bool debug = false;
/*---------------------------------------------------*/
int main() {
int n;
cin >> n;
rep(j, n) {
bool ok = true;
int a, b = 0, c = 0;
rep(i, 10) {
cin >> a;
if (a > b)
b = a;
else if (a > c)
c = a;
else
ok = false;
}
if (ok)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define REP(i, a, b) for (int i = (a); i < int(b); i++)
#define all(x) (x).begin(), x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x % (mod))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pi;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int ddx[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
bool debug = false;
/*---------------------------------------------------*/
int main() {
int n;
cin >> n;
rep(j, n) {
bool ok = true;
int a, b = 0, c = 0;
rep(i, 10) {
cin >> a;
if (a > b)
b = a;
else if (a > c)
c = a;
else
ok = false;
}
if (ok)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 306
| 4
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define MAXN 2555
#define INF 0x3f3f3f3f
#define v first
#define b second
using namespace std;
queue<int> q;
queue<int> p;
int s[15];
bool flag;
void dfs(int x) {
if (x == 10) {
flag = true;
return;
}
if (s[x] > q.front()) {
q.push(s[x]);
dfs(x + 1);
q.pop();
}
if (s[x] > p.front()) {
p.push(s[x]);
dfs(x + 1);
p.pop();
}
return;
}
int main() {
int t;
scanf("%d", &t);
q.push(0);
p.push(0);
while (t--) {
flag = false;
for (int i = 0; i < 10; i++)
scanf("%d", &s[i]);
dfs(0);
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define MAXN 2555
#define INF 0x3f3f3f3f
#define v first
#define b second
using namespace std;
stack<int> q;
stack<int> p;
int s[15];
bool flag;
void dfs(int x) {
if (x == 10) {
flag = true;
return;
}
if (s[x] > q.top()) {
q.push(s[x]);
dfs(x + 1);
q.pop();
}
if (s[x] > p.top()) {
p.push(s[x]);
dfs(x + 1);
p.pop();
}
return;
}
int main() {
int t;
scanf("%d", &t);
q.push(0);
p.push(0);
while (t--) {
flag = false;
for (int i = 0; i < 10; i++)
scanf("%d", &s[i]);
dfs(0);
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
|
[["-", 36, 36, 0, 30, 0, 43, 39, 344, 141, 78], ["+", 36, 36, 0, 30, 0, 43, 39, 344, 141, 78], ["-", 15, 339, 51, 16, 12, 2, 63, 118, 119, 120], ["+", 15, 339, 51, 16, 12, 2, 63, 118, 119, 120]]
| 1
| 257
| 8
|
#include <cstdio>
using namespace std;
int n;
int a[11];
int main() {
scanf("%d", &n);
for (int t = 0; t < n; ++t) {
int l = 0, r = 0;
for (int i = 0; i < 10; ++i)
scanf("%d", &a[i]);
bool flag = false;
for (int i = 0; i < 10; ++i) {
if (r > l) {
if (a[i] > r)
r = a[i];
else if (a[i] > l)
l = a[i];
else
flag = true;
} else {
if (a[i] > l)
l = a[i];
else if (a[i] > r)
r = a[i];
else
flag = true;
}
}
if (flag)
printf("NO");
else
printf("YES");
}
return 0;
}
|
#include <cstdio>
using namespace std;
int n;
int a[11];
int main() {
scanf("%d", &n);
for (int t = 0; t < n; ++t) {
int l = 0, r = 0;
for (int i = 0; i < 10; ++i)
scanf("%d", &a[i]);
bool flag = false;
for (int i = 0; i < 10; ++i) {
if (r > l) {
if (a[i] > r)
r = a[i];
else if (a[i] > l)
l = a[i];
else
flag = true;
} else {
if (a[i] > l)
l = a[i];
else if (a[i] > r)
r = a[i];
else
flag = true;
}
}
if (flag)
printf("NO\n");
else
printf("YES\n");
}
return 0;
}
|
[["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 213
| 2
|
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int res = 0;
int saiki(int ball[], int ttB, int ttC, int res) {
if (res == 10)
return res;
if (ball[res] > ttB) {
return saiki(ball, ball[res], ttC, res + 1);
}
if (ball[res] > ttC) {
return saiki(ball, ttB, ball[res], res + 1);
}
return res;
}
int main(void) {
int a, b;
int ball[11];
int ttB = 0, ttC = 0;
int n;
scanf("%d", &n);
for (a = 0; a < n; a++) {
for (b = 0; b < 10; b++) {
ball[b] = 0;
}
ttB = 0;
ttC = 0;
res = 0;
for (b = 0; b < 10; b++) {
scanf("%d", &ball[b]);
}
res = max(res, saiki(ball, ttB, ttC, res));
if (res == 10)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}
|
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int res = 0;
int saiki(int ball[], int ttB, int ttC, int res) {
if (res == 10)
return res;
if (ball[res] > ttB) {
return saiki(ball, ball[res], ttC, res + 1);
}
if (ball[res] > ttC) {
return saiki(ball, ttB, ball[res], res + 1);
}
return res;
}
int main(void) {
int a, b;
int ball[11];
int ttB = 0, ttC = 0;
int n;
scanf("%d", &n);
for (a = 0; a < n; a++) {
for (b = 0; b < 10; b++) {
ball[b] = 0;
}
ttB = 0;
ttC = 0;
res = 0;
for (b = 0; b < 10; b++) {
scanf("%d", &ball[b]);
}
res = max(res, saiki(ball, ttB, ttC, res));
if (res == 10)
printf("YES\n");
else
printf("NO\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
|
<?php
fscanf(STDIN,"%d",$n);
print "$n\n";
for($i=0;$i<$n;$i++){
$a=0;
$b=0;
$f=0;
fscanf(STDIN,"%d %d %d %d %d %d %d %d %d %d",$ar[0],$ar[1],$ar[2],$ar[3],$ar[4],$ar[5],$ar[6],$ar[7],$ar[8],$ar[9]);
for($j=0;$j<10;$j++){
if($ar[$j]>$a&&$ar[$j]>$b){
if($a>$b)$a=$ar[$j];
else $b=$ar[$j];
}
else if($ar[$j]>$a)$a=$ar[$j];
else if($ar[$j]>$b)$b=$ar[$j];
else $f=1;
}
if($f==1)print "NO\n";
else print "YES\n";
}
?>
|
<?php
fscanf(STDIN,"%d",$n);
for($i=0;$i<$n;$i++){
$a=0;
$b=0;
$f=0;
fscanf(STDIN,"%d %d %d %d %d %d %d %d %d %d",$ar[0],$ar[1],$ar[2],$ar[3],$ar[4],$ar[5],$ar[6],$ar[7],$ar[8],$ar[9]);
for($j=0;$j<10;$j++){
if($ar[$j]>$a&&$ar[$j]>$b){
if($a>$b)$a=$ar[$j];
else $b=$ar[$j];
}
else if($ar[$j]>$a)$a=$ar[$j];
else if($ar[$j]>$b)$b=$ar[$j];
else $f=1;
}
if($f==1)print "NO\n";
else print "YES\n";
}
?>
|
[["-", 36, 36, 0, 493, 0, 1, 0, 619, 0, 620], ["-", 0, 493, 0, 1, 0, 619, 0, 609, 0, 62], ["-", 0, 1, 0, 619, 0, 609, 0, 606, 0, 607], ["-", 0, 1, 0, 619, 0, 609, 0, 606, 0, 141], ["-", 0, 493, 0, 1, 0, 619, 0, 609, 0, 44], ["-", 36, 36, 36, 36, 0, 493, 0, 1, 0, 35]]
| 6
| 267
| 7
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
public class Main {
public static void main(String args[]) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String line;
br.readLine();
while ((line = br.readLine()) != null) {
if (line.equals(""))
break;
String[] splited = line.split(" ");
int[] ints = new int[10];
for (int i = 0; i < 10; i++)
ints[i] = Integer.parseInt(splited[i]);
int tB = ints[0], tC = -1;
boolean can = true;
for (int i = 1; i < 10; i++) {
if (tB > tC) {
if (ints[i] > tB) {
tB = ints[i];
continue;
}
if (ints[i] > tC) {
tC = ints[i];
continue;
}
can = false;
break;
} else {
if (ints[i] > tC) {
tC = ints[i];
continue;
}
if (ints[i] > tB) {
tB = ints[i];
continue;
}
can = false;
break;
}
}
System.out.println((can) ? "Yes" : "No");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
public class Main {
public static void main(String args[]) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String line;
br.readLine();
while ((line = br.readLine()) != null) {
if (line.equals(""))
break;
String[] splited = line.split(" ");
int[] ints = new int[10];
for (int i = 0; i < 10; i++)
ints[i] = Integer.parseInt(splited[i]);
int tB = ints[0], tC = -1;
boolean can = true;
for (int i = 1; i < 10; i++) {
if (tB > tC) {
if (ints[i] > tB) {
tB = ints[i];
continue;
}
if (ints[i] > tC) {
tC = ints[i];
continue;
}
can = false;
break;
} else {
if (ints[i] > tC) {
tC = ints[i];
continue;
}
if (ints[i] > tB) {
tB = ints[i];
continue;
}
can = false;
break;
}
}
System.out.println((can) ? "YES" : "NO");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
[["-", 0, 492, 3, 4, 0, 510, 64, 5, 0, 491], ["+", 0, 492, 3, 4, 0, 510, 64, 5, 0, 491], ["-", 0, 492, 3, 4, 0, 510, 75, 5, 0, 491], ["+", 0, 492, 3, 4, 0, 510, 75, 5, 0, 491]]
| 3
| 330
| 4
|
import java.io.IOException;
import java.util.*;
/**
*/
class Main {
final static int N = 10;
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
in.nextLine();
while (in.hasNext()) {
String[] dataset_str = in.nextLine().split(" ");
List<Integer> dataset = new ArrayList<>();
for (int i = 0; i < dataset_str.length; i++) {
dataset.add(Integer.parseInt(dataset_str[i]));
}
if (solve(dataset, 0, 0, 0)) {
System.out.println("Yes");
} else {
System.out.println("No");
}
}
}
public static boolean solve(List<Integer> dataset, int i, int left,
int right) {
if (i == dataset.size())
return true;
if (dataset.get(i) > left && solve(dataset, i + 1, dataset.get(i), right)) {
return true;
}
if (dataset.get(i) > right && solve(dataset, i + 1, left, dataset.get(i))) {
return true;
}
return false;
}
}
|
import java.io.IOException;
import java.util.*;
/**
*/
class Main {
final static int N = 10;
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
in.nextLine();
while (in.hasNext()) {
String[] dataset_str = in.nextLine().split(" ");
List<Integer> dataset = new ArrayList<>();
for (int i = 0; i < dataset_str.length; i++) {
dataset.add(Integer.parseInt(dataset_str[i]));
}
if (solve(dataset, 0, 0, 0)) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
}
public static boolean solve(List<Integer> dataset, int i, int left,
int right) {
if (i == dataset.size())
return true;
if (dataset.get(i) > left && solve(dataset, i + 1, dataset.get(i), right)) {
return true;
}
if (dataset.get(i) > right && solve(dataset, i + 1, left, dataset.get(i))) {
return true;
}
return false;
}
}
|
[["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491], ["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491]]
| 3
| 286
| 4
|
import java.io.BufferedInputStream;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(new BufferedInputStream(System.in));
int n;
while (cin.hasNext()) {
n = cin.nextInt();
int a[] = new int[10];
while (n > 0) {
for (int i = 0; i < 10; ++i) {
a[i] = cin.nextInt();
}
int l, r;
l = r = 0;
boolean ans = true;
for (int i = 0; i < 10; ++i) {
if (a[i] > l) {
l = a[i];
} else if (a[i] > r) {
r = a[i];
} else {
ans = false;
break;
}
}
System.out.format("%s", ans ? "YES" : "NO");
n--;
}
}
}
}
|
import java.io.BufferedInputStream;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(new BufferedInputStream(System.in));
int n;
while (cin.hasNext()) {
n = cin.nextInt();
int a[] = new int[10];
while (n > 0) {
for (int i = 0; i < 10; ++i) {
a[i] = cin.nextInt();
}
int l, r;
l = r = 0;
boolean ans = true;
for (int i = 0; i < 10; ++i) {
if (a[i] > l) {
l = a[i];
} else if (a[i] > r) {
r = a[i];
} else {
ans = false;
break;
}
}
System.out.format("%s\n", ans ? "YES" : "NO");
n--;
}
}
}
}
|
[["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 44]]
| 3
| 215
| 1
|
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[] ball = new int[11];
for (int i = 0; i < 10; i++) {
ball[i] = sc.nextInt();
}
boolean can = true;
for (int i = 0; i < (1 << 10); i++) {
can = true;
int s1 = 0;
int s2 = 0;
for (int j = 0; j < 10; j++) {
if ((i >> j) % 2 == 0) {
if (s1 < ball[j]) {
s1 = ball[j];
} else {
can = false;
}
} else {
if (s2 < ball[j]) {
s2 = ball[j];
} else {
can = false;
}
}
if (can)
break;
}
}
String ans = "YES";
if (!can)
ans = "NO";
System.out.println(ans);
}
}
}
|
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[] ball = new int[11];
for (int i = 0; i < 10; i++) {
ball[i] = sc.nextInt();
}
boolean can = true;
for (int i = 0; i < (1 << 10); i++) {
can = true;
int s1 = 0;
int s2 = 0;
for (int j = 0; j < 10; j++) {
if ((i >> j) % 2 == 0) {
if (s1 < ball[j]) {
s1 = ball[j];
} else {
can = false;
}
} else {
if (s2 < ball[j]) {
s2 = ball[j];
} else {
can = false;
}
}
}
if (can)
break;
}
String ans = "YES";
if (!can)
ans = "NO";
System.out.println(ans);
}
}
}
|
[["+", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46], ["-", 0, 7, 8, 196, 0, 7, 8, 196, 0, 46]]
| 3
| 246
| 2
|
import java.lang.*;
import java.math.*;
import java.util.*;
public class Main {
Scanner sc = new Scanner(System.in);
void run() { // greedy
int n = sc.nextInt();
for (int i = 0; i < n; i++) {
int val = 0;
int val2 = 0;
boolean ans = true;
for (int j = 0; j < 10; j++) {
int ball = sc.nextInt();
if (ball > val) {
val = ball;
}
else if (ball > val2) {
val2 = val;
val = ball;
} else {
ans = false;
break;
}
}
System.out.println(ans ? "YES" : "NO");
}
}
public static void main(String[] args) {
Main m = new Main();
m.run();
}
}
|
import java.lang.*;
import java.math.*;
import java.util.*;
public class Main {
Scanner sc = new Scanner(System.in);
void run() { // greedy
int n = sc.nextInt();
for (int i = 0; i < n; i++) {
int val = 0;
int val2 = 0;
boolean ans = true;
for (int j = 0; j < 10; j++) {
int ball = sc.nextInt();
if (ball > val) {
val = ball;
}
else if (ball > val2) {
val2 = ball;
} else {
ans = false;
}
}
System.out.println(ans ? "YES" : "NO");
}
}
public static void main(String[] args) {
Main m = new Main();
m.run();
}
}
|
[["-", 75, 57, 64, 196, 0, 1, 0, 11, 12, 22], ["-", 0, 57, 75, 57, 64, 196, 0, 1, 0, 35], ["-", 75, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["-", 75, 57, 64, 196, 0, 1, 0, 11, 17, 32], ["-", 0, 57, 75, 57, 75, 196, 0, 1, 0, 35], ["-", 0, 57, 75, 57, 75, 196, 0, 93, 0, 94]]
| 3
| 190
| 6
|
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
private static final int LEFT = 0;
private static final int RIGHT = 1;
private static final int EndOfDirection = 2;
private static ArrayList<Integer> a = new ArrayList<Integer>(10);
private static ArrayList<Integer> left = new ArrayList<Integer>(10);
private static ArrayList<Integer> right = new ArrayList<Integer>(10);
private static ArrayList<String> result = new ArrayList<String>();
private static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int numDataSet = sc.nextInt();
for (int i = 0; i < numDataSet; i++) {
pushBallsToA();
if (popBallsAscendingOrder()) {
result.add("YES");
} else {
result.add("NO");
}
}
for (int i = 0; i < result.size(); i++) {
System.out.println(result.get(i));
}
}
public static void setA(ArrayList<Integer> a) { Main.a = a; }
public static void pushBallsToA() {
a.clear();
for (int i = 0; i < 10; i++) {
a.add(sc.nextInt());
}
}
public static boolean popBallsAscendingOrder() {
left.clear();
right.clear();
for (int directionBall1 = LEFT; directionBall1 < EndOfDirection;
directionBall1++) {
for (int directionBall2 = LEFT; directionBall2 < EndOfDirection;
directionBall2++) {
for (int directionBall3 = LEFT; directionBall3 < EndOfDirection;
directionBall3++) {
for (int directionBall4 = LEFT; directionBall4 < EndOfDirection;
directionBall4++) {
for (int directionBall5 = LEFT; directionBall5 < EndOfDirection;
directionBall5++) {
for (int directionBall6 = LEFT; directionBall6 < EndOfDirection;
directionBall6++) {
for (int directionBall7 = LEFT; directionBall7 < EndOfDirection;
directionBall7++) {
for (int directionBall8 = LEFT;
directionBall8 < EndOfDirection; directionBall8++) {
for (int directionBall9 = LEFT;
directionBall9 < EndOfDirection; directionBall9++) {
for (int directionBall10 = LEFT;
directionBall10 < EndOfDirection;
directionBall10++) {
popBall(directionBall1, 0);
popBall(directionBall2, 1);
popBall(directionBall3, 2);
popBall(directionBall4, 3);
popBall(directionBall5, 4);
popBall(directionBall6, 5);
popBall(directionBall7, 6);
popBall(directionBall8, 7);
popBall(directionBall9, 8);
popBall(directionBall10, 9);
/*
System.out.print("left:");
for(int i = 0; i < left.size(); i++){
System.out.print(left.get(i) + " ");
}
System.out.println();
System.out.print("right:");
for(int i = 0; i < right.size(); i++){
System.out.print(right.get(i) + " ");
}
System.out.println();
*/
if (isAscendingOrder(left) && isAscendingOrder(right)) {
return true;
}
left.clear();
right.clear();
}
}
}
}
}
}
}
}
}
}
return false;
}
private static void popBall(int direction, int indexBall) {
switch (direction) {
case LEFT:
left.add(a.get(indexBall));
break;
case RIGHT:
right.add(a.get(indexBall));
break;
}
}
public static boolean isAscendingOrder(ArrayList<Integer> list) {
for (int i = 0; i < list.size() - 2; i++) {
if (list.get(i) > list.get(i + 1)) {
return false;
}
}
return true;
}
}
|
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
private static final int LEFT = 0;
private static final int RIGHT = 1;
private static final int EndOfDirection = 2;
private static ArrayList<Integer> a = new ArrayList<Integer>(10);
private static ArrayList<Integer> left = new ArrayList<Integer>(10);
private static ArrayList<Integer> right = new ArrayList<Integer>(10);
private static ArrayList<String> result = new ArrayList<String>();
private static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int numDataSet = sc.nextInt();
for (int i = 0; i < numDataSet; i++) {
pushBallsToA();
if (popBallsAscendingOrder()) {
result.add("YES");
} else {
result.add("NO");
}
}
for (int i = 0; i < result.size(); i++) {
System.out.println(result.get(i));
}
}
public static void setA(ArrayList<Integer> a) { Main.a = a; }
public static void pushBallsToA() {
a.clear();
for (int i = 0; i < 10; i++) {
a.add(sc.nextInt());
}
}
public static boolean popBallsAscendingOrder() {
left.clear();
right.clear();
for (int directionBall1 = LEFT; directionBall1 < EndOfDirection;
directionBall1++) {
for (int directionBall2 = LEFT; directionBall2 < EndOfDirection;
directionBall2++) {
for (int directionBall3 = LEFT; directionBall3 < EndOfDirection;
directionBall3++) {
for (int directionBall4 = LEFT; directionBall4 < EndOfDirection;
directionBall4++) {
for (int directionBall5 = LEFT; directionBall5 < EndOfDirection;
directionBall5++) {
for (int directionBall6 = LEFT; directionBall6 < EndOfDirection;
directionBall6++) {
for (int directionBall7 = LEFT; directionBall7 < EndOfDirection;
directionBall7++) {
for (int directionBall8 = LEFT;
directionBall8 < EndOfDirection; directionBall8++) {
for (int directionBall9 = LEFT;
directionBall9 < EndOfDirection; directionBall9++) {
for (int directionBall10 = LEFT;
directionBall10 < EndOfDirection;
directionBall10++) {
popBall(directionBall1, 0);
popBall(directionBall2, 1);
popBall(directionBall3, 2);
popBall(directionBall4, 3);
popBall(directionBall5, 4);
popBall(directionBall6, 5);
popBall(directionBall7, 6);
popBall(directionBall8, 7);
popBall(directionBall9, 8);
popBall(directionBall10, 9);
if (isAscendingOrder(left) && isAscendingOrder(right)) {
return true;
}
left.clear();
right.clear();
}
}
}
}
}
}
}
}
}
}
return false;
}
private static void popBall(int direction, int indexBall) {
switch (direction) {
case LEFT:
left.add(a.get(indexBall));
break;
case RIGHT:
right.add(a.get(indexBall));
break;
}
}
public static boolean isAscendingOrder(ArrayList<Integer> list) {
for (int i = 0; i < list.size() - 1; i++) {
if (list.get(i) > list.get(i + 1)) {
return false;
}
}
return true;
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499]]
| 3
| 684
| 2
|
#include <stdio.h>
#include <string.h>
int ball[11], r[11], l[11], flag;
void senten(int x, int y, int k) {
if (x >= 10) {
flag = 1;
return;
}
if (flag) {
return;
}
if (ball[x] > r[y - 1]) {
r[y] = ball[x];
senten(x + 1, y + 1, k);
}
if (ball[x] > l[k - 1]) {
l[k] = ball[x];
senten(x + 1, y, k + 1);
}
}
int main() {
int t;
scanf("%d", &t);
for (int i = 0; i < t; i++) {
memset(r, 0, sizeof(r));
memset(l, 0, sizeof(l));
flag = 0;
for (int j = 0; j < 10; j++)
scanf("%d", &ball[j]);
senten(0, 1, 1);
if (flag)
printf("YSE\n");
else
printf("NO\n");
}
}
|
#include <stdio.h>
#include <string.h>
int ball[11], r[11], l[11], flag;
void senten(int x, int y, int k) {
if (x == 10) {
flag = 1;
return;
}
if (flag) {
return;
}
if (ball[x] > r[y - 1]) {
r[y] = ball[x];
senten(x + 1, y + 1, k);
}
if (ball[x] > l[k - 1]) {
l[k] = ball[x];
senten(x + 1, y, k + 1);
}
}
int main() {
int t;
scanf("%d", &t);
for (int i = 0; i < t; i++) {
memset(r, 0, sizeof(r));
memset(l, 0, sizeof(l));
flag = 0;
for (int j = 0; j < 10; j++)
scanf("%d", &ball[j]);
senten(0, 1, 1);
if (flag)
printf("YES\n");
else
printf("NO\n");
}
}
|
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 60], ["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 0
| 256
| 4
|
#include <stdio.h>
int main(void) {
int i, j, n, ball, b[10], k, c[10], l, NO;
scanf("%d", &n);
for (i = 0; i < n; i++) {
for (j = 0; j < 10; j++) {
b[j] = 0;
c[j] = 0;
}
k = 0;
l = 0;
NO = 0;
for (j = 0; j < 10; j++) {
scanf("%d", &ball);
if (k == 0) {
b[k++] = ball;
} else if (b[k - 1] < ball) {
b[k++] = ball;
}
else if (l == 0) {
c[l++] = ball;
} else if (c[k - 1] < ball) {
c[l++] = ball;
} else {
NO = 1;
}
if (j == 9) {
if (NO == 0) {
printf("YES\n");
} else {
printf("NO\n");
}
}
}
}
return (0);
}
|
#include <stdio.h>
int main(void) {
int i, j, n, ball, b[10], k, c[10], l, NO;
scanf("%d", &n);
for (i = 0; i < n; i++) {
for (j = 0; j < 10; j++) {
b[j] = 0;
c[j] = 0;
}
k = 0;
l = 0;
NO = 0;
for (j = 0; j < 10; j++) {
scanf("%d", &ball);
if (k == 0) {
b[k++] = ball;
} else if (b[k - 1] < ball) {
b[k++] = ball;
} else if (l == 0) {
c[l++] = ball;
} else if (c[l - 1] < ball) {
c[l++] = ball;
} else {
NO = 1;
}
if (j == 9) {
if (NO == 0) {
printf("YES\n");
} else {
printf("NO\n");
}
}
}
}
return (0);
}
|
[["-", 15, 23, 0, 16, 31, 69, 71, 16, 31, 22], ["+", 15, 23, 0, 16, 31, 69, 71, 16, 31, 22]]
| 0
| 249
| 2
|
a[10];
int dfs(int l, int r, int i) {
if (i > 9)
return 1;
if (a[i] > l && dfs(a[i], r, i + 1))
return 1;
if (a[i] > r && dfs(l, a[i], i + 1))
return 1;
return 0;
}
main(n) {
scanf("%d", &n);
for (; n; n--)
scanf("%d%d%d%d%d%d%d%d%d%d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5],
&a[6], &a[7], &a[8], &a[9]),
dfs(0, 0, 0) ? puts("YES\n") : puts("NO\n");
return 0;
}
|
a[10];
int dfs(int l, int r, int i) {
if (i > 9)
return 1;
if (a[i] > l && dfs(a[i], r, i + 1))
return 1;
if (a[i] > r && dfs(l, a[i], i + 1))
return 1;
return 0;
}
main(n) {
scanf("%d", &n);
for (; n; n--)
scanf("%d%d%d%d%d%d%d%d%d%d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5],
&a[6], &a[7], &a[8], &a[9]),
dfs(0, 0, 0) ? puts("YES") : puts("NO");
return 0;
}
|
[["-", 12, 41, 64, 2, 3, 4, 0, 5, 0, 44], ["-", 12, 41, 75, 2, 3, 4, 0, 5, 0, 44]]
| 0
| 202
| 2
|
#include <stdio.h>
int func(int *a, int *b1, int *b2, int c, int c1, int c2) {
int ret = 0;
if (c < 10) {
if ((ret == 0) && (*(a + c) > *(b1 + c1))) {
*(b1 + c1 + 1) = *(a + c);
ret = func(a, b1, b2, c + 1, c1 + 1, c2);
}
if ((ret == 0) && (*(a + c) > *(b2 + c2))) {
*(b2 + c2 + 1) = *(a + c * 4);
ret = func(a, b1, b2, c + 1, c1, c2 + 1);
}
} else {
ret = 1;
}
return ret;
}
int main() {
int n, i, a[10], b1[11] = {0}, b2[11] = {0};
int ret = 0;
scanf("%d", &n);
while (n > 0) {
for (i = 0; i < 10; i++)
scanf("%d", &a[i]);
ret = func(&a[0], &b1[0], &b2[0], 0, 0, 0);
if (ret == 1)
printf("YES\n");
else
printf("NO\n");
n--;
}
return 0;
}
|
#include <stdio.h>
int func(int *a, int *b1, int *b2, int c, int c1, int c2) {
int ret = 0;
if (c < 10) {
if ((ret == 0) && (*(a + c) > *(b1 + c1))) {
*(b1 + c1 + 1) = *(a + c);
ret = func(a, b1, b2, c + 1, c1 + 1, c2);
}
if ((ret == 0) && (*(a + c) > *(b2 + c2))) {
*(b2 + c2 + 1) = *(a + c);
ret = func(a, b1, b2, c + 1, c1, c2 + 1);
}
} else {
ret = 1;
}
return ret;
}
int main() {
int n, i, a[10], b1[10] = {0}, b2[10] = {0};
int ret = 0;
scanf("%d", &n);
while (n > 0) {
for (i = 0; i < 10; i++)
scanf("%d", &a[i]);
ret = func(&a[0], &b1[0], &b2[0], 0, 0, 0);
if (ret == 1)
printf("YES\n");
else
printf("NO\n");
n--;
}
return 0;
}
|
[["-", 12, 66, 28, 23, 0, 16, 12, 16, 17, 48], ["-", 12, 66, 28, 23, 0, 16, 12, 16, 12, 13], ["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]]
| 0
| 320
| 6
|
#include <algorithm>
#include <cstdio>
#include <stack>
using namespace std;
stack<int> B, C;
int A[10];
bool dfs(int index) {
bool ret = false;
char s[11];
if (index >= 10) {
return true;
}
for (int i = 0; i < 11; i++) {
if (i < index)
s[i] = '>';
else
s[i] = 0;
}
if (B.empty() || B.top() < A[index]) {
B.push(A[index]);
// printf("%spush %d into B\n", s, A[index]);
ret = dfs(index + 1);
// printf("%s%s. pop %d from B\n", s, ret ? "succeeded" : "failed",
// A[index]);
B.pop();
}
if (!ret && (C.empty() || C.top() < A[index])) {
C.push(A[index]);
// printf("%spush %d into C\n", s, A[index]);
ret = dfs(index + 1);
// printf("%s%s. pop %d from C\n", s, ret ? "succeeded" : "failed",
// A[index]);
C.pop();
}
return ret;
}
bool solve() {
while (!B.empty())
B.pop();
while (!C.empty())
C.pop();
B.push(A[0]);
bool ret = dfs(1);
B.pop();
return ret;
}
int main() {
int N;
scanf("%d", &N);
for (int i = 0; i < N; i++) {
for (int j = 0; j < 10; j++) {
scanf("%d", A + j);
}
if (solve()) {
printf("Yes\n");
} else {
printf("No\n");
}
}
return 0;
}
|
#include <algorithm>
#include <cstdio>
#include <stack>
using namespace std;
stack<int> B, C;
int A[10];
bool dfs(int index) {
bool ret = false;
char s[11];
if (index >= 10) {
return true;
}
for (int i = 0; i < 11; i++) {
if (i < index)
s[i] = '>';
else
s[i] = 0;
}
if (B.empty() || B.top() < A[index]) {
B.push(A[index]);
// printf("%spush %d into B\n", s, A[index]);
ret = dfs(index + 1);
// printf("%s%s. pop %d from B\n", s, ret ? "succeeded" : "failed",
// A[index]);
B.pop();
}
if (!ret && (C.empty() || C.top() < A[index])) {
C.push(A[index]);
// printf("%spush %d into C\n", s, A[index]);
ret = dfs(index + 1);
// printf("%s%s. pop %d from C\n", s, ret ? "succeeded" : "failed",
// A[index]);
C.pop();
}
return ret;
}
bool solve() {
while (!B.empty())
B.pop();
while (!C.empty())
C.pop();
B.push(A[0]);
bool ret = dfs(1);
B.pop();
return ret;
}
int main() {
int N;
scanf("%d", &N);
for (int i = 0; i < N; i++) {
for (int j = 0; j < 10; j++) {
scanf("%d", A + j);
}
if (solve()) {
printf("YES\n");
} else {
printf("NO\n");
}
}
return 0;
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 354
| 4
|
/*
* AOJ 0033: Ball
* 题意:序号为1-10的10个球,按一定排列顺序进入2个队列之一,最终每队入队球的序号都为增序的方案是否存在。
* 类型:贪心
* 算法:对于每个球,若大于队列顶端元素,则可以记录该情况并继续递归。每次优先加入左边,可保证左边的顶端元素大于右边。
*/
#include <iostream>
using namespace std;
int balls[10];
int main() {
//每次就先看左边能不能放,能放就放入,否则再看右边,右边也不能放,则不存在方案
int n;
cin >> n;
while (n--) {
for (int i = 0; i < 10; i++)
cin >> balls[i];
int l = 0, r = 0;
bool flag = true;
for (int i = 0; i < 10; i++) {
if (balls[i] > l) {
l = balls[i];
} else if (balls[i] > r) {
r = balls[i];
} else {
flag = false;
break;
}
}
if (flag)
cout << "NO" << endl;
else
cout << "YES" << endl;
}
}
// int a[10];
// int main() {
// int T;
// scanf("%d", &T);
// while (T--) {
// bool ans = true;
// for (int i = 0; i < 10; ++i) {
// scanf("%d", &a[i]);
// }
// int l, r;
// l = r = 0;
// for (int i = 0; i < 10; ++i) {
// if (a[i] > l) {
// l = a[i];
// } else if (a[i] > r) {
// r = a[i];
// } else {
// ans = false;
// break;
// }
// }
// printf("%s\n", ans ? "YES" : "NO");
// }
// return 0;
// }
|
/*
* AOJ 0033: Ball
* 题意:序号为1-10的10个球,按一定排列顺序进入2个队列之一,最终每队入队球的序号都为增序的方案是否存在。
* 类型:贪心
* 算法:对于每个球,若大于队列顶端元素,则可以记录该情况并继续递归。每次优先加入左边,可保证左边的顶端元素大于右边。
*/
#include <iostream>
using namespace std;
int balls[10];
int main() {
//每次就先看左边能不能放,能放就放入,否则再看右边,右边也不能放,则不存在方案
int n;
cin >> n;
while (n--) {
for (int i = 0; i < 10; i++)
cin >> balls[i];
int l = 0, r = 0;
bool flag = true;
for (int i = 0; i < 10; i++) {
if (balls[i] > l) {
l = balls[i];
} else if (balls[i] > r) {
r = balls[i];
} else {
flag = false;
break;
}
}
if (flag)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
// int a[10];
// int main() {
// int T;
// scanf("%d", &T);
// while (T--) {
// bool ans = true;
// for (int i = 0; i < 10; ++i) {
// scanf("%d", &a[i]);
// }
// int l, r;
// l = r = 0;
// for (int i = 0; i < 10; ++i) {
// if (a[i] > l) {
// l = a[i];
// } else if (a[i] > r) {
// r = a[i];
// } else {
// ans = false;
// break;
// }
// }
// printf("%s\n", ans ? "YES" : "NO");
// }
// return 0;
// }
|
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
| 1
| 177
| 4
|
#include <algorithm>
#include <cstdio>
#define HEIGHT 10
using namespace std;
int a[HEIGHT];
/*
void solve(){
bool f=true;
int right,left;
right = left = 0;
for(int i=0;i<HEIGHT;i++){
if(right<a[i] && left<a[i]){
if(right<left){
left = a[i];
} else {
right = a[i];
}
} else if(right<a[i]){
right = a[i];
} else if(left<a[i]){
left = a[i];
} else {
f = false;
break;
}
}
if(f) printf("YES");
else printf("NO");
}*/
bool back(int right, int left, int n) {
if (n == 10)
return true;
bool result = false;
if (right < a[n])
result = result || back(a[n], left, n + 1);
if (left < a[n])
result = result || back(right, a[n], n + 1);
return result;
}
void solve() {
if (back(0, 0, 0))
printf("YES");
else
printf("NO");
}
int main() {
int lp;
scanf("%d", &lp);
for (int i = 0; i < lp; i++) {
for (int j = 0; j < HEIGHT; j++) {
scanf(" %d", &a[j]);
}
solve();
}
return 0;
}
|
#include <algorithm>
#include <cstdio>
#define HEIGHT 10
using namespace std;
int a[HEIGHT];
/*
void solve(){
bool f=true;
int right,left;
right = left = 0;
for(int i=0;i<HEIGHT;i++){
if(right<a[i] && left<a[i]){
if(right<left){
left = a[i];
} else {
right = a[i];
}
} else if(right<a[i]){
right = a[i];
} else if(left<a[i]){
left = a[i];
} else {
f = false;
break;
}
}
if(f) printf("YES");
else printf("NO");
}*/
bool back(int right, int left, int n) {
if (n == 10)
return true;
bool result = false;
if (right < a[n])
result = result || back(a[n], left, n + 1);
if (left < a[n])
result = result || back(right, a[n], n + 1);
return result;
}
void solve() {
if (back(0, 0, 0))
printf("YES\n");
else
printf("NO\n");
}
int main() {
int lp;
scanf("%d", &lp);
for (int i = 0; i < lp; i++) {
for (int j = 0; j < HEIGHT; j++) {
scanf(" %d", &a[j]);
}
solve();
}
return 0;
}
|
[["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
| 1
| 206
| 2
|
#include <algorithm>
#include <cstdio>
#define HEIGHT 10
using namespace std;
int a[HEIGHT];
void solve() {
bool f = true;
int right, left;
right = left = 0;
for (int i = 0; i < HEIGHT; i++) {
if (right < a[i] && left < a[i]) {
if (right < left) {
left = a[i];
} else {
right = a[i];
}
} else if (right < a[i]) {
right = a[i];
} else if (left < a[i]) {
left = a[i];
} else {
f = false;
break;
}
}
if (f)
printf("YES");
else
printf("NO");
}
int main() {
int lp;
scanf("%d", &lp);
for (int i = 0; i < lp; i++) {
for (int j = 0; j < HEIGHT; j++) {
scanf(" %d", &a[j]);
}
solve();
}
return 0;
}
|
#include <algorithm>
#include <cstdio>
#define HEIGHT 10
using namespace std;
int a[HEIGHT];
void solve() {
bool f = true;
int right, left;
right = left = 0;
for (int i = 0; i < HEIGHT; i++) {
if (right < a[i] && left < a[i]) {
if (right < left) {
left = a[i];
} else {
right = a[i];
}
} else if (right < a[i]) {
right = a[i];
} else if (left < a[i]) {
left = a[i];
} else {
f = false;
break;
}
}
if (f) {
printf("YES\n");
} else {
printf("NO\n");
}
}
int main() {
int lp;
scanf("%d", &lp);
for (int i = 0; i < lp; i++) {
for (int j = 0; j < HEIGHT; j++) {
scanf(" %d", &a[j]);
}
solve();
}
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
| 1
| 235
| 10
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
int n, b, B = 0, C = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
B = 0;
C = 0;
for (int j = 0; j < 10; j++) {
scanf("%d", &b);
if (min(B, C) < b) {
if (B > C && B < b)
B = b;
else
C = b;
} else {
B = 11;
C = 11;
}
}
if (B == 10 || C == 10)
puts("YES");
else
puts("NO");
}
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
int n, b, B = 0, C = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
B = 0;
C = 0;
for (int j = 0; j < 10; j++) {
scanf("%d", &b);
if (min(B, C) < b) {
if ((B > C && B < b) || C > b)
B = b;
else
C = b;
} else {
B = 11;
C = 11;
}
}
if (B == 10 || C == 10)
puts("YES");
else
puts("NO");
}
return 0;
}
|
[["+", 0, 57, 15, 339, 51, 16, 31, 23, 0, 24], ["+", 51, 16, 31, 23, 0, 16, 12, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 23, 0, 25], ["+", 64, 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, 47]]
| 1
| 172
| 6
|
#include <iostream>
#include <string.h>
using namespace std;
int N;
int balls[10];
bool dfs(int n, int a, int b) {
if (n == 10)
return true;
if (balls[n] > a)
return dfs(n + 1, balls[n], b);
if (balls[n] > b)
return dfs(n + 1, a, balls[n]);
return false;
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
for (int j = 0; j < 10; j++) {
cin >> balls[j];
}
if (dfs(0, 0, balls[0]))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
#include <iostream>
#include <string.h>
using namespace std;
int N;
int balls[10];
bool dfs(int n, int a, int b) {
if (n == 10)
return true;
if (balls[n] > a)
return dfs(n + 1, balls[n], b);
if (balls[n] > b)
return dfs(n + 1, a, balls[n]);
return false;
}
int main() {
cin >> N;
for (int i = 0; i < N; i++) {
for (int j = 0; j < 10; j++) {
cin >> balls[j];
}
if (dfs(0, 0, 0))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
|
[["-", 15, 339, 51, 2, 3, 4, 0, 69, 28, 22], ["-", 51, 2, 3, 4, 0, 69, 341, 342, 0, 70], ["-", 51, 2, 3, 4, 0, 69, 341, 342, 0, 73]]
| 1
| 171
| 3
|
#include <iostream>
using namespace std;
int main() {
int a, b, c;
int ca = 0, cb = 0;
while (scanf("%d, %d, %d", &a, &b, &c) + 1) {
if ((a * a) + (b * b) == c * c) {
ca++;
}
if (a == b) {
cb++;
}
}
printf("%d\n%d/n", ca, cb);
return 0;
}
|
#include <iostream>
using namespace std;
int main() {
int a, b, c;
int ca = 0, cb = 0;
while (scanf("%d, %d, %d", &a, &b, &c) + 1) {
if ((a * a) + (b * b) == c * c) {
ca++;
}
if (a == b) {
cb++;
}
}
printf("%d\n%d\n", ca, cb);
return 0;
}
|
[["-", 0, 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, 44]]
| 1
| 100
| 3
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define PI acos(-1.0)
#define ALL(A) ((A).begin(), (A).end())
#define vsort(v) sort(v.begin(), v.end())
#define FOR(I, A, B) for (int I = (A); I < (B); ++I)
int main() {
int a, b, c;
int sq = 0, hishi = 0;
while (scanf("%d,%d,%d\n", &a, &b, &c) == 1) {
if (a * a + b * b == c * c)
sq++;
if (a == b)
hishi++;
}
cout << sq << endl;
cout << hishi << endl;
}
|
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define PI acos(-1.0)
#define ALL(A) ((A).begin(), (A).end())
#define vsort(v) sort(v.begin(), v.end())
#define FOR(I, A, B) for (int I = (A); I < (B); ++I)
int main() {
int a, b, c;
int sq = 0, hishi = 0;
while (scanf("%d,%d,%d", &a, &b, &c) == 3) {
if (a * a + b * b == c * c)
sq++;
if (a == b)
hishi++;
}
cout << sq << endl;
cout << hishi << endl;
}
|
[["-", 51, 16, 31, 2, 3, 4, 0, 5, 0, 44], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 13]]
| 1
| 147
| 3
|
#include "bits/stdc++.h"
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort((c).begin(), (c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())
using namespace std;
using LL = long long int;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;
const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;
const int dy[] = {0, 1, 0, -1};
const int dx[] = {1, 0, -1, 0};
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int rectangle = 0, diamondShape = 0;
int a, b, c;
char c1, c2;
while (cin >> a >> c1 >> b >> c2 >> c) {
if (a == b) {
diamondShape++;
} else if (a * a + b * b == c * c) {
rectangle++;
}
}
cout << diamondShape << endl;
cout << rectangle << endl;
return 0;
}
|
#include "bits/stdc++.h"
#define ALL(a) (a).begin(), (a).end()
#define SORT(c) sort((c).begin(), (c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())
using namespace std;
using LL = long long int;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;
const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;
const int dy[] = {0, 1, 0, -1};
const int dx[] = {1, 0, -1, 0};
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int rectangle = 0, diamondShape = 0;
int a, b, c;
char c1, c2;
while (cin >> a >> c1 >> b >> c2 >> c) {
if (a == b) {
diamondShape++;
} else if (a * a + b * b == c * c) {
rectangle++;
}
}
cout << rectangle << endl;
cout << diamondShape << endl;
return 0;
}
|
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
| 1
| 375
| 4
|
#include <cstdio>
//#include<algorithm>
using namespace std;
int a, b, c, tyo, hi;
int main() {
while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
if (c * c == a * a + b * b)
tyo++;
if (a == b)
hi++;
}
printf("%d %d", tyo, hi);
return 0;
}
|
#include <cstdio>
//#include<algorithm>
using namespace std;
int a, b, c, tyo, hi;
int main() {
while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
if (c * c == a * a + b * b)
tyo++;
if (a == b)
hi++;
}
printf("%d\n%d\n", tyo, hi);
return 0;
}
|
[["-", 0, 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, 44]]
| 1
| 86
| 5
|
#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LOOP(i, x, n) for (int i = x; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF = 1000000007;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
int a, b, c;
char k;
int ans1 = 0, ans2 = 0;
while (cin >> a >> k >> b >> k >> c) {
if ((a * a + b * b) == c * c)
ans1++;
else if (a == b && a != c)
ans2++;
}
cout << ans1 << endl;
cout << ans2 << endl;
return 0;
}
|
#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LOOP(i, x, n) for (int i = x; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF = 1000000007;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
int a, b, c;
char k;
int ans1 = 0, ans2 = 0;
while (cin >> a >> k >> b >> k >> c) {
if ((a * a + b * b) == c * c)
ans1++;
else if (a == b)
ans2++;
}
cout << ans1 << endl;
cout << ans2 << endl;
return 0;
}
|
[["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 98], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
| 1
| 186
| 4
|
#include <cstdio>
using namespace std;
int main() {
int a, b, c, x = 0, y = 0;
while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
if (a == b)
x++;
if (a * a + b * b == c * c)
y++;
}
printf("%d?\n%d?\n", y, x);
return 0;
}
|
#include <cstdio>
int main() {
int a, b, c, x = 0, y = 0;
while (scanf("%d,%d,%d", &a, &b, &c) != EOF) {
if (a == b)
x++;
if (a * a + b * b == c * c)
y++;
}
printf("%d\n%d\n", y, x);
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 340, 0, 233], ["-", 36, 36, 36, 36, 0, 30, 0, 340, 0, 256], ["-", 36, 36, 36, 36, 0, 30, 0, 340, 0, 22], ["-", 36, 36, 36, 36, 0, 30, 0, 340, 0, 35], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 92
| 8
|
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int sides[3];
int square = 0, para = 0;
while (scanf("%d,%d,%d", &sides[0], &sides[1], &sides[2]) != EOF) {
//??£?????¢???check
if (sides[0] * sides[0] + sides[1] * sides[1] == sides[2] * sides[2]) {
square++;
}
//??????????????¢???check
else if (sides[0] == sides[1]) {
para++;
}
cout << square << endl << para << endl;
}
}
|
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
int sides[3];
int tyoho = 0, para = 0;
while (scanf("%d,%d,%d", &sides[0], &sides[1], &sides[2]) != EOF) {
//????????¢???check
if (sides[0] * sides[0] + sides[1] * sides[1] == sides[2] * sides[2]) {
tyoho++;
}
//??????????????¢???check
else if (sides[0] == sides[1]) {
para++;
}
}
cout << tyoho << endl << para << endl;
}
|
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 49, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 75, 76, 0, 57, 64, 9, 0, 46], ["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
| 1
| 127
| 8
|
#include <cstdio>
using namespace std;
int main() {
int x, y, r, hisi = 0, tyou = 0;
while (scanf("%d,%d,%d ", &x, &y, &r) == 3) {
if (x == y) {
hisi++;
}
if (x * x + y * y == r * r) {
tyou++;
}
}
printf("%d\n%d\n", hisi, tyou);
}
|
#include <cstdio>
using namespace std;
int main() {
int x, y, r, hisi = 0, tyou = 0;
while (scanf("%d,%d,%d ", &x, &y, &r) == 3) {
if (x == y) {
hisi++;
}
if (x * x + y * y == r * r) {
tyou++;
}
}
printf("%d\n%d\n", tyou, hisi);
}
|
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
| 1
| 93
| 4
|
#include <iostream>
using namespace std;
int main() {
int a, b, d;
char c;
int ans[2] = {0};
while (cin >> a >> c >> b >> c >> d) {
if (a == b)
ans[0]++;
else if (a * a + b * b == c * c)
ans[1]++;
}
cout << ans[1] << endl;
cout << ans[0] << endl;
}
|
#include <iostream>
using namespace std;
int main() {
int a, b, d;
char c;
int ans[2] = {0};
while (cin >> a >> c >> b >> c >> d) {
if (a == b)
ans[0]++;
else if (a * a + b * b == d * d)
ans[1]++;
}
cout << ans[1] << endl;
cout << ans[0] << endl;
}
|
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]]
| 1
| 99
| 4
|
c1,c2 = 0,0
while arr = gets
a,b,c = arr.chomp.split(";").map(&:to_i)
unless (c**2 == a**2 + b**2) && (a == b)
c1 = c1 + 1 if c**2 == a**2 + b**2
c2 = c2 + 1 if a == b
end
end
puts c1; puts c2
|
c1,c2 = 0,0
while arr = gets
a,b,c = arr.chomp.split(",").map(&:to_i)
unless (c**2 == a**2 + b**2) && (a == b)
c1 = c1 + 1 if c**2 == a**2 + b**2
c2 = c2 + 1 if a == b
end
end
puts c1; puts c2
|
[["-", 12, 652, 486, 652, 3, 4, 0, 557, 0, 6], ["+", 12, 652, 486, 652, 3, 4, 0, 557, 0, 6]]
| 4
| 86
| 2
|
cho_n = 0
hishi_n = 0
while str = gets do
a, b, c = str.chomp.split(" ").map(&:to_i)
if a == b
hishi_n += 1
end
if a * a + b * b == c * c
cho_n += 1
end
end
puts cho_n
puts hishi_n
|
cho_n = 0
hishi_n = 0
while str = gets do
a, b, c = str.chomp.split(",").map(&:to_i)
if a == b
hishi_n += 1
end
if a * a + b * b == c * c
cho_n += 1
end
end
puts cho_n
puts hishi_n
|
[["-", 12, 652, 486, 652, 3, 4, 0, 557, 0, 6], ["+", 12, 652, 486, 652, 3, 4, 0, 557, 0, 6]]
| 4
| 62
| 2
|
hishi = 0
tyou = 0
while input = gets do
a,b,c = input.chop.split(",").map{|n| n.to_i}
if a == b then
hishi += 1
elsif a**2 + b**2 == c**2 then
tyou += 1
end
end
puts hishi,tyou
|
hishi = 0
tyou = 0
while input = gets do
a,b,c = input.chop.split(",").map{|n| n.to_i}
if a == b then
hishi += 1
elsif a**2 + b**2 == c**2 then
tyou += 1
end
end
puts tyou,hishi
|
[["-", 36, 36, 0, 493, 0, 652, 3, 4, 0, 22], ["-", 36, 36, 0, 493, 0, 652, 3, 4, 0, 21], ["+", 36, 36, 0, 493, 0, 652, 3, 4, 0, 21], ["+", 36, 36, 0, 493, 0, 652, 3, 4, 0, 22]]
| 4
| 67
| 4
|
#!/usr/local/bin/ruby
rec,dia=0,0
while line=gets
arr=line.split(",").map(&:to_i)
a=arr[0].to_i
b=arr[1].to_i
c=arr[2].to_i
if a==b
elsif a**2+b**2==c**2
dia+=1
end
end
puts "#{rec}"
puts "#{dia}"
|
#!/usr/local/bin/ruby
rec,dia=0,0
while line=gets
arr=line.split(",").map(&:to_i)
a=arr[0].to_i
b=arr[1].to_i
c=arr[2].to_i
if a==b
dia+=1
elsif a**2+b**2==c**2
rec+=1
end
end
puts "#{rec}"
puts "#{dia}"
|
[["+", 8, 170, 0, 121, 64, 749, 0, 755, 31, 22], ["+", 8, 170, 0, 121, 64, 749, 0, 755, 17, 107], ["+", 8, 170, 0, 121, 64, 749, 0, 755, 12, 612], ["-", 0, 121, 75, 759, 64, 749, 0, 755, 31, 22], ["+", 0, 121, 75, 759, 64, 749, 0, 755, 31, 22]]
| 4
| 85
| 5
|
s=0
n=0
while True:
try:
a,b,c = map(int, input().split())
except:
break
if a == b:
n+=1
elif c**2 == a**2 + b**2:
s+=1
print(str(s) + "\n" + str(n))
|
s=0
n=0
while True:
try:
a,b,c = map(int, input().split(","))
except:
break
if a == b:
n+=1
elif c**2 == a**2 + b**2:
s+=1
print(str(s) + "\n" + str(n))
|
[["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 654], ["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 3, 4, 0, 652, 3, 4, 0, 557, 0, 655]]
| 5
| 72
| 3
|
r, l = 0, 0
while True:
try:
a, b, c = list(map(int, input().split(',')))
if a == b: l += 1
elif (a ** 2) + (b ** 2) == c **2: r += 1
except:
break
print("%d %d" % (r, l))
|
r, l = 0, 0
while True:
try:
a, b, c = list(map(int, input().split(',')))
if a == b: l += 1
elif (a ** 2) + (b ** 2) == c **2: r += 1
except:
break
print("%d\n%d" % (r, l))
|
[["-", 0, 652, 3, 4, 0, 657, 31, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 657, 31, 557, 0, 6], ["+", 3, 4, 0, 657, 31, 557, 0, 6, 0, 44]]
| 5
| 79
| 4
|
n1 = n2 = 0
while True:
try:
a, b, c = map(int, line.split(','))
if a**2 + b**2 == c**2:
n1 += 1
elif a == b:
n2 += 1
except EOFError: break
print(n1)
print(n2)
|
# 0032
n1 = n2 = 0
while True:
try:
a, b, c = map(int, input().split(','))
if a**2 + b**2 == c**2:
n1 += 1
elif a == b:
n2 += 1
except EOFError: break
print(n1)
print(n2)
|
[["-", 12, 652, 3, 4, 0, 652, 63, 319, 500, 22], ["+", 3, 4, 0, 652, 63, 319, 500, 652, 63, 22], ["+", 0, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["+", 0, 652, 63, 319, 500, 652, 3, 4, 0, 25]]
| 5
| 65
| 4
|
import sys
rect = 0
hisi = 0
for line in sys.stdin.readlines():
x,y,z = list(map(int,line.split(',')))
if x**2 + y**2 == z**2:rect += 1
elif x == y : hisi +=1
print(rect,hisi)
|
import sys
rect = 0
hisi = 0
for line in sys.stdin.readlines():
x,y,z = list(map(int,line.split(',')))
if x**2 + y**2 == z**2:rect += 1
elif x == y : hisi +=1
print(rect)
print(hisi)
|
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
| 5
| 71
| 4
|
rectangles = 0 ; lozenges = 0
while True:
try:
a,b,c, = list(map(int,input().split(',')))
if a*a + b*b == c*c: rectangle += 1
else:
if a == b: lozenges += 1
except: break
print(rectangles) ; print(lozenges)
|
rectangles = 0 ; lozenges = 0
while True:
try:
a,b,c, = list(map(int,input().split(',')))
if a*a + b*b == c*c: rectangles += 1
else:
if a == b: lozenges += 1
else: pass
except: break
print(rectangles) ; print(lozenges)
|
[["-", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["+", 75, 76, 8, 196, 0, 57, 75, 76, 0, 95], ["+", 75, 76, 8, 196, 0, 57, 75, 76, 0, 102], ["+", 0, 57, 75, 76, 8, 196, 0, 674, 0, 675]]
| 5
| 75
| 5
|
import sys
c1 = c2 = 0
for line in sys.stdin:
a, b, c = map(int, line.split(','))
if a**2 + b**2 == c**2:
c1 += 1
elif a == b:
c2 += 1
print(c1, c2)
|
import sys
c1 = c2 = 0
for line in sys.stdin:
a, b, c = map(int, line.split(','))
if a**2 + b**2 == c**2:
c1 += 1
elif a == b:
c2 += 1
print(c1)
print(c2)
|
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
| 5
| 63
| 4
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
public class Main {
public static void main(String args[]) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String line;
while ((line = br.readLine()) != null) {
if (line.equals(""))
break;
String[] splited = line.split(",");
int[] ints = new int[10];
for (int i = 0; i < 10; i++)
ints[i] = Integer.parseInt(splited[i]);
int v1 = Integer.parseInt(splited[10]),
v2 = Integer.parseInt(splited[11]);
int sumL = 0;
for (int i = 0; i < 10; i++)
sumL += ints[i];
double t = sumL + 0.0 / (v1 + v2);
double x = t * v1;
int ans = 0, sumTmp = 0;
for (int i = 0; i < 10; i++) {
sumTmp += ints[i];
if (sumTmp <= x) {
ans = i + 1;
break;
}
}
System.out.println(ans);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
public class Main {
public static void main(String args[]) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String line;
while ((line = br.readLine()) != null) {
if (line.equals(""))
break;
String[] splited = line.split(",");
int[] ints = new int[10];
for (int i = 0; i < 10; i++)
ints[i] = Integer.parseInt(splited[i]);
int v1 = Integer.parseInt(splited[10]),
v2 = Integer.parseInt(splited[11]);
int sumL = 0;
for (int i = 0; i < 10; i++)
sumL += ints[i];
double t = (sumL + 0.0) / (v1 + v2);
double x = t * v1;
int ans = 0, sumTmp = 0; // System.out.println("sL"+sumL+"t"+t+""+x+"x");
for (int i = 0; i < 10; i++) {
sumTmp += ints[i];
if (sumTmp >= x) {
ans = i + 1;
break;
}
}
System.out.println(ans);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
[["+", 0, 503, 49, 200, 51, 16, 31, 23, 0, 24], ["+", 0, 503, 49, 200, 51, 16, 31, 23, 0, 25], ["-", 8, 196, 0, 57, 15, 15, 0, 16, 17, 19], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 20]]
| 3
| 296
| 4
|
import java.io.*;
import java.lang.Math.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
try {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
StringTokenizer st = new StringTokenizer(line, ",");
int[] sta = new int[10];
int tra1, tra2;
for (int i = 0; i < 10; i++)
sta[i] = Integer.parseInt(st.nextToken());
tra1 = Integer.parseInt(st.nextToken());
tra2 = Integer.parseInt(st.nextToken());
int sum = 0;
for (int i = 0; i < 10; i++)
sum += sta[i];
double t = (double)sum / (tra1 + tra2);
// System.out.println(t+" "+sum);
sum = 0;
for (int i = 0; i < 10; i++) {
if (tra1 * t > sum && tra1 * t < (sum + sta[i]))
System.out.println(i + 1);
sum += sta[i];
}
}
} catch (java.lang.NumberFormatException e) {
System.out.println(e);
}
}
}
|
import java.io.*;
import java.lang.Math.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
try {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
StringTokenizer st = new StringTokenizer(line, ",");
int[] sta = new int[10];
int tra1, tra2;
for (int i = 0; i < 10; i++)
sta[i] = Integer.parseInt(st.nextToken());
tra1 = Integer.parseInt(st.nextToken());
tra2 = Integer.parseInt(st.nextToken());
int sum = 0;
for (int i = 0; i < 10; i++)
sum += sta[i];
double t = (double)sum / (tra1 + tra2);
// System.out.println(t+" "+sum);
sum = 0;
for (int i = 0; i < 10; i++) {
if (tra1 * t > sum && tra1 * t <= (sum + sta[i]))
System.out.println(i + 1);
sum += sta[i];
}
}
} catch (java.lang.NumberFormatException e) {
System.out.println(e);
}
}
}
|
[["-", 0, 57, 15, 15, 0, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 19]]
| 3
| 289
| 2
|
import java.util.*;
public class Main {
private static final Scanner scan =
new Scanner(System.in).useDelimiter("[,\\s]+");
public static void main(String[] args) {
int[] l = new int[10];
int sum1 = 0, sum2 = 0;
double time = 0, tX = 0;
while (scan.hasNext()) {
for (int i = 0; i < 10; i++) {
l[i] = scan.nextInt();
}
int v1 = scan.nextInt();
int v2 = scan.nextInt();
for (int i = 0; i < 10; i++) {
sum1 += l[i];
}
time = (double)(sum1 / (v2 + v1));
tX = (double)v1 * time;
for (int i = 0; i < 10; i++) {
sum2 += l[i];
if (tX <= sum2) {
System.out.printf("%d\n", i + 1);
sum1 = 0;
sum2 = 0;
break;
}
}
}
}
}
|
import java.util.*;
public class Main {
private static final Scanner scan =
new Scanner(System.in).useDelimiter("[,\\s]+");
public static void main(String[] args) {
int[] l = new int[10];
int sum1 = 0, sum2 = 0;
double time = 0, tX = 0;
while (scan.hasNext()) {
for (int i = 0; i < 10; i++) {
l[i] = scan.nextInt();
}
int v1 = scan.nextInt();
int v2 = scan.nextInt();
for (int i = 0; i < 10; i++) {
sum1 += l[i];
}
time = (double)sum1 / (double)(v2 + v1);
tX = (double)v1 * time;
for (int i = 0; i < 10; i++) {
sum2 += l[i];
if (tX <= sum2) {
System.out.printf("%d\n", i + 1);
sum1 = 0;
sum2 = 0;
break;
}
}
}
}
}
|
[["-", 0, 1, 0, 11, 12, 74, 51, 23, 0, 24], ["+", 0, 11, 12, 16, 12, 74, 39, 511, 0, 512], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 0, 25], ["+", 0, 11, 12, 16, 12, 74, 51, 23, 0, 24], ["-", 12, 74, 51, 23, 0, 16, 12, 23, 0, 25]]
| 3
| 235
| 5
|
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String str = sc.next();
String[] strArr = str.split(",");
int[] l = new int[10];
int d = 0;
for (int i = 0; i < 10; i++) {
l[i] = Integer.parseInt(strArr[i]);
d += l[i];
}
int[] v = {Integer.parseInt(strArr[10]), Integer.parseInt(strArr[11])};
double t = (double)d / (v[0] + v[1]);
d = 0;
for (int i = 0; i < 10; i++) {
if (v[0] * t <= d) {
System.out.println(i);
break;
} else {
d += l[i];
}
}
}
}
}
|
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String str = sc.next();
String[] strArr = str.split(",");
int[] l = new int[10];
int d = 0;
for (int i = 0; i < 10; i++) {
l[i] = Integer.parseInt(strArr[i]);
d += l[i];
}
int[] v = {Integer.parseInt(strArr[10]), Integer.parseInt(strArr[11])};
double t = (double)d / (v[0] + v[1]);
d = 0;
for (int i = 0; i < 11; i++) {
if (v[0] * t <= d) {
System.out.println(i);
break;
} else {
d += l[i];
}
}
}
}
}
|
[["-", 0, 52, 8, 196, 0, 7, 15, 16, 12, 499], ["+", 0, 52, 8, 196, 0, 7, 15, 16, 12, 499]]
| 3
| 222
| 2
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
String input = scanner.nextLine();
String[] dataset = input.split(",");
int[] sectionLen = new int[10];
double totalLen = 0;
for (int i = 0; i < sectionLen.length; i++) {
sectionLen[i] = Integer.parseInt(dataset[i]);
totalLen += (double)sectionLen[i];
}
int v1 = Integer.parseInt(dataset[10]);
int v2 = Integer.parseInt(dataset[11]);
double time = totalLen / (v1 + v2);
double distance = v1 * time;
for (int i = 0; i < sectionLen.length; i++) {
distance -= sectionLen[i];
if (distance <= 0) {
System.out.println(i + 1);
}
}
}
}
}
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
String input = scanner.nextLine();
String[] dataset = input.split(",");
int[] sectionLen = new int[10];
double totalLen = 0;
for (int i = 0; i < sectionLen.length; i++) {
sectionLen[i] = Integer.parseInt(dataset[i]);
totalLen += (double)sectionLen[i];
}
int v1 = Integer.parseInt(dataset[10]);
int v2 = Integer.parseInt(dataset[11]);
double time = totalLen / (v1 + v2);
double distance = v1 * time;
for (int i = 0; i < sectionLen.length; i++) {
distance -= sectionLen[i];
if (distance <= 0) {
System.out.println(i + 1);
break;
}
}
}
}
}
|
[["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 94], ["+", 8, 196, 0, 57, 64, 196, 0, 93, 0, 35]]
| 3
| 215
| 2
|
#include <stdio.h>
int main() {
int i, j;
float x, l[10] = {0}, v1, v2, lsum, lsum2, sure;
while (scanf("%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f\n", &l[0], &l[1], &l[2],
&l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1,
&v2) != EOF) {
lsum = 0;
x = 0;
for (i = 0; i < 10; i++)
lsum = lsum + l[i];
x = lsum / (v1 + v2);
sure = v1 * x;
lsum2 = 0;
for (i = 0; i < 10; i++)
lsum2 = lsum2 + l[i];
if (lsum2 >= sure) {
printf("%d\n", i + 1);
break;
}
}
return 0;
}
|
#include <stdio.h>
int main() {
int i, j;
float x, l[10] = {0}, v1, v2, lsum, lsum2, sure;
while (scanf("%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f\n", &l[0], &l[1], &l[2],
&l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1,
&v2) != EOF) {
lsum = 0;
x = 0;
for (i = 0; i < 10; i++)
lsum = lsum + l[i];
x = lsum / (v1 + v2);
sure = v1 * x;
lsum2 = 0;
for (i = 0; i < 10; i++) {
lsum2 = lsum2 + l[i];
if (lsum2 >= sure) {
printf("%d\n", i + 1);
break;
}
}
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
| 0
| 212
| 2
|
#include <stdio.h>
int main() {
double L[10];
double V1, V2;
double meet_pos;
double railway_lenth;
int cnt1, cnt2;
int output[50];
cnt2 = 0;
while (1) {
if (scanf("%lf,", &L[0]) == EOF) {
break;
}
for (cnt1 = 1; cnt1 < 10; cnt1++) {
scanf("%lf,", &L[cnt1]);
}
scanf("%lf,%lf", &V1, &V2);
railway_lenth = 0;
for (cnt1 = 0; cnt1 < 10; cnt1++) {
railway_lenth += L[cnt1];
}
meet_pos = railway_lenth * V1 / (V1 + V2);
cnt1 = 0;
railway_lenth = 0;
while (railway_lenth <= meet_pos) {
railway_lenth += L[cnt1];
cnt1++;
}
output[cnt2] = cnt1;
cnt2++;
}
for (cnt1 = 0; cnt1 < cnt2; cnt1++) {
printf("%d\n", output[cnt1]);
}
return 0;
}
|
#include <stdio.h>
int main() {
double L[10];
double V1, V2;
double meet_pos;
double railway_lenth;
int cnt1, cnt2;
int output[50];
cnt2 = 0;
while (1) {
if (scanf("%lf,", &L[0]) == EOF) {
break;
}
for (cnt1 = 1; cnt1 < 10; cnt1++) {
scanf("%lf,", &L[cnt1]);
}
scanf("%lf,%lf", &V1, &V2);
railway_lenth = 0;
for (cnt1 = 0; cnt1 < 10; cnt1++) {
railway_lenth += L[cnt1];
}
meet_pos = railway_lenth * V1 / (V1 + V2);
cnt1 = 0;
railway_lenth = 0;
while (railway_lenth < meet_pos) {
railway_lenth += L[cnt1];
cnt1++;
}
output[cnt2] = cnt1;
cnt2++;
}
for (cnt1 = 0; cnt1 < cnt2; cnt1++) {
printf("%d\n", output[cnt1]);
}
return 0;
}
|
[["-", 8, 9, 0, 52, 15, 23, 0, 16, 17, 19], ["+", 8, 9, 0, 52, 15, 23, 0, 16, 17, 18]]
| 0
| 213
| 38
|
main() {
int a[11], b, c, i;
a[0] = 0;
for (;;) {
for (i = 0; i < 10; i++)
if (scanf("%d,", &a[i + 1]) == -1)
break;
else
a[i + 1] += a[i];
if (i != 10)
break;
if (scanf("%d,%d", &b, &c) == -1)
break;
for (i = 1; i < 10; i++)
if (a[i] >= (double)a[10] / (b + c) * b) {
printf("%d\n", i);
break;
}
}
return 0;
}
|
main() {
int a[11], b, c, i;
a[0] = 0;
for (;;) {
for (i = 0; i < 10; i++)
if (scanf("%d,", &a[i + 1]) == -1)
break;
else
a[i + 1] += a[i];
if (i != 10)
break;
if (scanf("%d,%d", &b, &c) == -1)
break;
for (i = 1; i < 11; i++)
if (a[i] >= (double)a[10] / (b + c) * b) {
printf("%d\n", i);
break;
}
}
return 0;
}
|
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 12, 13]]
| 0
| 158
| 2
|
/* AOJ 0034
*
* http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0034
*/
#include <stdio.h>
#define DEBUG 1
#define true 1
#define false 0
int meetat(int *input, int v1, int v2) {
int total;
int i;
float fat;
int d;
total = 0;
for (i = 0; i < 10; i++)
total += input[i];
fat = total * 1.0 / (v1 + v2) * v1;
i = 0;
d = 0;
while (fat > d) {
d += input[i];
i++;
}
return i;
}
int main() {
int i;
int n;
int input[11];
int v1, v2;
while (true) {
for (i = 0; i < 10; i++) {
scanf("%d,", input + i);
}
scanf("%d,", &v1);
if (scanf("%d", &v2) != 1)
break;
input[10] = 0;
if (DEBUG) {
for (i = 0; i < 10; i++) {
printf("%d,", input[i]);
}
printf("%d.", v1);
printf("%d", v2);
printf("\n");
}
printf("%d\n", meetat(input, v1, v2));
}
return 0;
}
|
/* AOJ 0034
*
* http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0034
*/
#include <stdio.h>
#define DEBUG 0
#define true 1
#define false 0
int meetat(int *input, int v1, int v2) {
int total;
int i;
float fat;
int d;
total = 0;
for (i = 0; i < 10; i++)
total += input[i];
fat = total * 1.0 / (v1 + v2) * v1;
i = 0;
d = 0;
while (fat > d) {
d += input[i];
i++;
}
return i;
}
int main() {
int i;
int n;
int input[11];
int v1, v2;
while (true) {
for (i = 0; i < 10; i++) {
scanf("%d,", input + i);
}
scanf("%d,", &v1);
if (scanf("%d", &v2) != 1)
break;
input[10] = 0;
if (DEBUG) {
for (i = 0; i < 10; i++) {
printf("%d,", input[i]);
}
printf("%d.", v1);
printf("%d", v2);
printf("\n");
}
printf("%d\n", meetat(input, v1, v2));
}
return 0;
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
| 0
| 272
| 2
|
#include <stdio.h>
main() {
int b[15], v, v1, v2, i, c, j, p;
float s;
while (scanf("%d,", &b[1]) != EOF) {
s = b[1];
c = 0;
for (i = 2; i <= 10; i++) {
scanf("%d,", &b[i]);
s += b[i];
}
scanf("%d,%d", &v1, &v2);
if (v1 < v2) {
v = v1;
j = 1;
} else {
v = v2;
j = 10;
}
s /= (v1 + v2);
s *= v;
if (j == 1) {
for (i = j; i <= 10; i++) {
c += b[i];
if (c >= s) {
p = i;
break;
}
}
} else {
for (i = 10; i > 0; i--) {
c += b[i];
if (c >= s) {
p = i;
break;
}
}
}
printf("%d\n", p);
}
return 0;
}
|
#include <stdio.h>
main() {
int b[15], v, v1, v2, i, c, j, p;
float s;
while (scanf("%d,", &b[1]) != EOF) {
s = b[1];
c = 0;
for (i = 2; i <= 10; i++) {
scanf("%d,", &b[i]);
s += b[i];
}
scanf("%d,%d", &v1, &v2);
if (v1 < v2) {
v = v1;
j = 1;
} else {
v = v2;
j = 10;
}
s /= (v1 + v2);
s *= v;
if (j == 1) {
for (i = j; i <= 10; i++) {
c += b[i];
if (c >= s) {
p = i;
break;
}
}
} else {
for (i = 10; i > 0; i--) {
c += b[i];
if (c > s) {
p = i;
break;
}
}
}
printf("%d\n", p);
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47]]
| 0
| 244
| 2
|
#include <stdio.h>
int main() {
int sum = 0, l[10], v1, v2, i;
double t, r;
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", l, l + 1, l + 2, l + 3,
l + 4, l + 5, l + 6, l + 7, l + 8, l + 9, &v1, &v2) != EOF) {
for (i = 0; i < 10; i++)
sum += l[i];
t = (double)sum / (v1 + v2);
r = v1 * t;
for (i = 0; i < 10; i++) {
r -= l[i];
if (r <= 0)
printf("%d\n", i + 1);
}
sum = 0;
}
return 0;
}
|
#include <stdio.h>
int main() {
int sum = 0, l[10], v1, v2, i;
double t, r;
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", l, l + 1, l + 2, l + 3,
l + 4, l + 5, l + 6, l + 7, l + 8, l + 9, &v1, &v2) != EOF) {
for (i = 0; i < 10; i++)
sum += l[i];
t = (double)sum / (v1 + v2);
r = v1 * t;
for (i = 0; i < 10; i++) {
r -= l[i];
if (r <= 0.0) {
printf("%d\n", i + 1);
break;
}
}
sum = 0;
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
| 0
| 172
| 6
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int len[10];
int v1, v2;
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &len[0], &len[1], &len[2],
&len[3], &len[4], &len[5], &len[6], &len[7], &len[8], &len[9],
&v1, &v2) != EOF) {
int accum[10] = {0};
accum[0] = len[0];
for (int i = 1; i < 10; i++) {
accum[i] += accum[i - 1] + len[i];
}
// accum[9] は合計の距離
double t = (double)accum[9] / (v1 + v2);
double dist = (double)v1 * t;
for (int i = 0; i < 10; i++) {
if (dist < accum[i]) {
cout << i + 1 << endl;
break;
}
}
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int len[10];
int v1, v2;
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &len[0], &len[1], &len[2],
&len[3], &len[4], &len[5], &len[6], &len[7], &len[8], &len[9],
&v1, &v2) != EOF) {
int accum[10] = {0};
accum[0] = len[0];
for (int i = 1; i < 10; i++) {
accum[i] += accum[i - 1] + len[i];
}
// accum[9] は合計の距離
double t = (double)accum[9] / (v1 + v2);
double dist = (double)v1 * t;
for (int i = 0; i < 10; i++) {
if (dist <= accum[i]) {
cout << i + 1 << endl;
break;
}
}
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
| 1
| 225
| 2
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int l[10], v1, v2, n, cnt;
double d, t;
char ch;
while (cin >> l[0] >> ch) {
n = l[0];
for (int i = 1; i < 10; i++) {
cin >> l[i] >> ch;
n += l[i];
}
cin >> v1 >> ch >> v2;
t = n / (v1 + v2);
d = v1 * t; //列車1の動く距離
cnt = 0;
while (d > 0) {
d -= l[cnt];
cnt++;
}
cout << cnt << endl;
}
return 0;
}
|
#include <iostream>
#include <string>
using namespace std;
int main() {
int l[10], v1, v2, cnt;
double n, d, t;
char ch;
while (cin >> l[0] >> ch) {
n = l[0];
for (int i = 1; i < 10; i++) {
cin >> l[i] >> ch;
n += l[i];
}
cin >> v1 >> ch >> v2;
t = n / (v1 + v2);
d = v1 * t; //列車1の動く距離
cnt = 0;
while (d > 0) {
d -= l[cnt];
cnt++;
}
cout << cnt << endl;
}
return 0;
}
|
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 21]]
| 1
| 144
| 4
|
#include <iostream>
using namespace std;
double l[11], a, b, sum, dis;
char d;
int main() {
while (cin >> l[1] >> d >> l[2] >> d >> l[3] >> d >> l[4] >> d >> l[5] >> d >>
l[6] >> d >> l[7] >> d >> l[8] >> d >> l[9] >> d >> l[10] >> d >> a >>
d >> b) {
sum = 0;
for (int i = 1; i <= 10; i++) {
sum++;
}
dis = 1.0 * sum * (a / (a + b));
sum = 0;
for (int i = 1; i <= 10; i++) {
sum += l[i];
if (sum >= dis) {
cout << i << endl;
break;
}
}
}
}
|
#include <iostream>
using namespace std;
double l[11], a, b, sum, dis;
char d;
int main() {
while (cin >> l[1] >> d >> l[2] >> d >> l[3] >> d >> l[4] >> d >> l[5] >> d >>
l[6] >> d >> l[7] >> d >> l[8] >> d >> l[9] >> d >> l[10] >> d >> a >>
d >> b) {
sum = 0;
for (int i = 1; i <= 10; i++) {
sum += l[i];
}
dis = 1.0 * sum * (a / (a + b));
sum = 0;
for (int i = 1; i <= 10; i++) {
sum += l[i];
if (sum >= dis) {
cout << i << endl;
break;
}
}
}
}
|
[["-", 0, 7, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 107], ["+", 8, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73]]
| 1
| 193
| 6
|
#include <bits/stdc++.h>
using namespace std;
double a[15], b;
char ch;
signed main(void) {
while (scanf("%d,", &a[1]) != EOF) {
for (int i = 2; i < 12; i++)
scanf("%d,", &a[i]);
scanf("%d", &a[12]);
b = 0;
for (int i = 1; i <= 10; i++)
b += a[i];
b = (b * a[11]) / (a[11] + a[12]);
for (int i = 1; i <= 10; i++) {
b -= a[i];
if (b <= 0) {
printf("%d\n", i);
break;
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
double a[15], b;
signed main(void) {
while (scanf("%lf,", &a[1]) != EOF) {
for (int i = 2; i < 12; i++)
scanf("%lf,", &a[i]);
scanf("%lf", &a[12]);
b = 0;
for (int i = 1; i <= 10; i++)
b += a[i];
b = (b * a[11]) / (a[11] + a[12]);
for (int i = 1; i <= 10; i++) {
b -= a[i];
if (b <= 0) {
printf("%d\n", i);
break;
}
}
}
}
|
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["-", 36, 36, 36, 36, 0, 30, 0, 43, 49, 22], ["-", 36, 36, 36, 36, 0, 30, 0, 43, 0, 35], ["-", 51, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["+", 51, 16, 31, 2, 3, 4, 0, 5, 0, 6], ["-", 8, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 8, 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
| 174
| 9
|
#include <iostream>
using namespace std;
int main() {
double l[10];
double v[2];
char c;
while (cin >> l[0] >> c >> l[1] >> c >> l[2] >> c >> l[3] >> c >> l[4] >> c >>
l[5] >> c >> l[6] >> c >> l[7] >> c >> l[8] >> c >> l[9] >> c >>
v[0] >> c >> v[1]) {
double a = 0;
for (int i = 0; i < 10; i++) {
a += l[i];
}
a = a * v[0] / (v[0] + v[1]);
for (int i = 0; i < 10; i++) {
a -= l[i];
if (a == 0) {
cout << i << endl;
} else if (a < 0) {
cout << i + 1 << endl;
goto c;
}
}
c:
a = 0;
}
}
|
#include <iostream>
using namespace std;
int main() {
double l[10];
double v[2];
char c;
while (cin >> l[0] >> c >> l[1] >> c >> l[2] >> c >> l[3] >> c >> l[4] >> c >>
l[5] >> c >> l[6] >> c >> l[7] >> c >> l[8] >> c >> l[9] >> c >>
v[0] >> c >> v[1]) {
double a = 0;
for (int i = 0; i < 10; i++) {
a += l[i];
}
a = a * v[0] / (v[0] + v[1]);
for (int i = 0; i < 10; i++) {
a -= l[i];
if (a == 0) {
cout << i + 1 << endl;
goto c;
} else if (a < 0) {
cout << i + 1 << endl;
goto c;
}
}
c:
a = 0;
}
}
|
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 126, 0, 127], ["+", 8, 9, 0, 57, 64, 9, 0, 126, 128, 129]]
| 1
| 227
| 5
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int w[10], a, b, i;
double t, d;
while (cin >> w[0]) {
for (i = 1; i < 10; i++)
scanf(",%d", &w[i]);
int sum[10] = {0};
sum[0] = w[0];
for (i = 1; i < 10; i++)
sum[i] += sum[i - 1] + w[i];
scanf("%d,%d", &a, &b);
t = (double)sum[9] / (a + b);
d = (double)t * a;
for (i = 0; i < 10; i++)
if (d <= sum[i]) {
cout << i + 1 << endl;
break;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int w[10], a, b, i;
double t, d;
while (cin >> w[0]) {
for (i = 1; i < 10; i++)
scanf(",%d", &w[i]);
int sum[10] = {0};
sum[0] = w[0];
for (i = 1; i < 10; i++)
sum[i] += sum[i - 1] + w[i];
scanf(",%d,%d", &a, &b);
t = (double)sum[9] / (a + b);
d = (double)t * a;
for (i = 0; i < 10; i++)
if (d <= sum[i]) {
cout << i + 1 << endl;
break;
}
}
}
|
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
| 1
| 188
| 2
|
#include <iostream>
#include <numeric>
int main() {
int lengthes[10];
char tmp;
while (std::cin >> lengthes[0] >> tmp >> lengthes[1] >> tmp >> lengthes[2] >>
tmp >> lengthes[3] >> tmp >> lengthes[4] >> tmp >> lengthes[5] >>
tmp >> lengthes[6] >> tmp >> lengthes[7] >> tmp >> lengthes[8] >>
tmp >> lengthes[9] >> tmp) {
int v1, v2;
std::cin >> v1 >> tmp >> v2;
int sum = std::accumulate(&lengthes[0], &lengthes[10], 0);
double sec = (double)(sum) / (v1 + v2);
double dist = v1 + sec;
int all = 0;
int index = 1;
for (auto length : lengthes) {
all += length;
if (dist < all) {
std::cout << index << std::endl;
break;
}
index++;
}
}
return 0;
}
|
#include <iostream>
#include <numeric>
int main() {
int lengthes[10];
char tmp;
while (std::cin >> lengthes[0] >> tmp >> lengthes[1] >> tmp >> lengthes[2] >>
tmp >> lengthes[3] >> tmp >> lengthes[4] >> tmp >> lengthes[5] >>
tmp >> lengthes[6] >> tmp >> lengthes[7] >> tmp >> lengthes[8] >>
tmp >> lengthes[9] >> tmp) {
int v1, v2;
std::cin >> v1 >> tmp >> v2;
int sum = std::accumulate(&lengthes[0], &lengthes[10], 0);
double sec = (double)(sum) / (v1 + v2);
double dist = v1 * sec;
int all = 0;
int index = 1;
for (auto length : lengthes) {
all += length;
if (dist <= all) {
std::cout << index << std::endl;
break;
}
index++;
}
}
return 0;
}
|
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 48], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
| 1
| 206
| 4
|
#include <stdio.h>
int main(void) {
int l[10];
while (scanf("%d", &l[0]) != EOF) {
int sum, v1, v2, vs, now = 0, i, j;
sum = l[0];
for (i = 1; i < 10; ++i) {
scanf(",%d", &l[i]);
sum += l[i];
}
scanf(",%d,%d", &v1, &v2);
vs = v1 + v2;
double t = (double)sum / (double)vs;
// printf("sum%d vs%d t%f\n", sum, vs, t);
for (i = 0; i < 10; ++i) {
if (now >= t * v1) {
printf("%d\n", i);
break;
}
now += l[i];
}
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int l[10];
while (scanf("%d", &l[0]) != EOF) {
int sum, v1, v2, vs, now = 0, i, j;
sum = l[0];
for (i = 1; i < 10; ++i) {
scanf(",%d", &l[i]);
sum += l[i];
}
scanf(",%d,%d", &v1, &v2);
vs = v1 + v2;
double t = (double)sum / (double)vs;
// printf("sum%d vs%d t%f\n", sum, vs, t);
for (i = 0; i <= 10; ++i) {
if (now >= t * v1) {
printf("%d\n", i);
break;
}
now += l[i];
}
}
return 0;
}
|
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
| 1
| 173
| 2
|
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
int v1, v2, ret;
double sum = 0;
vector<int> l(10, 0);
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
&l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1,
&v2) != EOF) {
for (int i = 0; i < 10; i++) {
sum += l[i];
}
sum /= (v1 + v2);
sum *= v1;
// cout << sum << endl;
for (int i = 0; i < 10; i++) {
sum -= l[i];
if (sum <= 0) {
ret = i + 1;
break;
}
}
cout << ret << endl;
}
return 0;
}
|
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
int v1, v2, ret;
double sum = 0;
vector<int> l(10, 0);
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
&l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1,
&v2) != EOF) {
sum = 0;
for (int i = 0; i < 10; i++) {
sum += l[i];
}
sum /= (v1 + v2);
sum *= v1;
for (int i = 0; i < 10; i++) {
sum -= l[i];
if (sum <= 0) {
ret = i + 1;
break;
}
}
cout << ret << endl;
}
return 0;
}
|
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
| 1
| 240
| 4
|
#include <cstdio>
#include <iostream>
using namespace std;
const double EPS = 1.0e-6;
int main() {
int l[10];
int v1, v2;
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
&l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2) > 0) {
int suml = 0;
for (int i = 0; i < 10; i++) {
suml += l[i];
}
double time = 1.0 * suml / (v1 + v2);
double miti = time * v1 - EPS;
int ans = 0;
for (int i = 0, sl = 0; i < 10; i++) {
if (miti < sl) {
ans = i;
break;
}
sl += l[i];
}
cout << ans << endl;
}
return 0;
}
|
#include <cstdio>
#include <iostream>
using namespace std;
const double EPS = 1.0e-6;
int main() {
int l[10];
int v1, v2;
while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &l[0], &l[1], &l[2],
&l[3], &l[4], &l[5], &l[6], &l[7], &l[8], &l[9], &v1, &v2) > 0) {
int suml = 0;
for (int i = 0; i < 10; i++) {
suml += l[i];
}
double time = 1.0 * suml / (v1 + v2);
double miti = time * v1 - EPS;
int ans = 0;
for (int i = 0, sl = 0; i < 10 + 1; i++) {
if (miti < sl) {
ans = i;
break;
}
sl += l[i];
}
cout << ans << endl;
}
return 0;
}
|
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
| 1
| 215
| 2
|
for i in range(int(input())):
x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
det = (y1-y2) * (x3-x4) - (x1-x2) * (y3-y4)
if det<1e-12 :
print("YES")
else:
print("NO")
|
for i in range(int(input())):
x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
det = abs((y1-y2) * (x3-x4) - (x1-x2) * (y3-y4))
if det<1e-12 :
print("YES")
else:
print("NO")
|
[["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 657, 31, 23, 0, 24], ["+", 3, 4, 0, 657, 12, 657, 12, 23, 0, 25]]
| 5
| 85
| 3
|
n=eval(input())
for i in range(n):
a,b,c,d,e,f,g,h=list(map(float,input().split()))
# if a==c and g==e:print "YES"
# if a==c and g!=e:print "NO"
# if a!=c and g==e:print "NO"
# if a!=c and g!=e:
# if (d-b)/(c-a)==(h-f)/(g-e):print "YES"
# else:print "NO"
if (d-b)*(g-e)-(c-a)*(h-f)<1e-10:
print("YES")
else:
print("NO")
|
n=eval(input())
for i in range(n):
a,b,c,d,e,f,g,h=list(map(float,input().split()))
if -1e-10<(d-b)*(g-e)-(c-a)*(h-f)<1e-10:
print("YES")
else:
print("NO")
|
[["+", 8, 196, 0, 57, 15, 666, 0, 664, 17, 33], ["+", 8, 196, 0, 57, 15, 666, 0, 664, 28, 531], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18]]
| 5
| 94
| 3
|
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
if x1 == x2 and x3 == x4:
print("YES")
elif x1 == x2 or x3 == x4:
print("NO")
elif (y2 - y1) / (x2 - x1) - (y4 - y3) / (x4 - x3) < 1e-10:
print("YES")
else:
print("NO")
|
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
if x1 == x2 and x3 == x4:
print("YES")
elif x1 == x2 or x3 == x4:
print("NO")
elif abs((y2 - y1) / (x2 - x1) - (y4 - y3) / (x4 - x3)) < 1e-10:
print("YES")
else:
print("NO")
|
[["+", 0, 57, 75, 665, 15, 666, 0, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 657, 31, 23, 0, 24], ["+", 3, 4, 0, 657, 12, 657, 12, 23, 0, 25]]
| 5
| 115
| 3
|
for i in range(int(input())):
a,b,c,d,e,f,g,h = map(float,input().split())
if a == c:
print("YES" if e == g else "NO")
elif e == g:
print("NO")
else:
print("YES" if (b-d)/(a-c) - (f-h)/(e-g) < 1e-10 else "NO")
|
for i in range(int(input())):
a,b,c,d,e,f,g,h = map(float,input().split())
if a == c:
print("YES" if e == g else "NO")
elif e == g:
print("NO")
else:
print("YES" if abs((b-d)/(a-c) - (f-h)/(e-g)) < 1e-10 else "NO")
|
[["+", 3, 4, 0, 41, 0, 666, 0, 652, 63, 22], ["+", 3, 4, 0, 657, 31, 657, 31, 23, 0, 24], ["+", 3, 4, 0, 657, 12, 657, 12, 23, 0, 25]]
| 5
| 109
| 3
|
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
print('YES' if abs(x2 - x1)*(y4 - y3) - (x4 - x3)*(y2 - y1) < 1e-10 else 'NO')
|
n = int(input())
for i in range(n):
x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())
print('YES' if abs((x2 - x1)*(y4 - y3) - (x4 - x3)*(y2 - y1)) < 1e-10 else 'NO')
|
[["+", 3, 4, 0, 657, 31, 657, 31, 23, 0, 24], ["+", 3, 4, 0, 657, 12, 657, 12, 23, 0, 25]]
| 5
| 81
| 2
|
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int n;
while ((n = scn.nextInt()) != 0) {
long min = 0, max = -1000, buf = 0;
for (int i = 0; i < n; i++) {
buf += scn.nextLong();
max = Math.max(max, buf);
min = Math.min(min, buf);
}
System.out.println(max - min);
}
scn.close();
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int n;
while ((n = scn.nextInt()) != 0) {
long min = 0, max = -100000, buf = 0;
for (int i = 0; i < n; i++) {
buf += scn.nextLong();
max = Math.max(max, buf - min);
min = Math.min(min, buf);
}
System.out.println(max);
}
scn.close();
}
}
|
[["-", 8, 196, 0, 503, 49, 200, 51, 91, 439, 499], ["+", 8, 196, 0, 503, 49, 200, 51, 91, 439, 499], ["+", 0, 11, 12, 492, 3, 4, 0, 16, 17, 33], ["+", 0, 11, 12, 492, 3, 4, 0, 16, 12, 22], ["-", 0, 1, 0, 492, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 492, 3, 4, 0, 16, 12, 22]]
| 3
| 131
| 6
|
import java.util.*;
class Main {
static int INF = 1 >> 32;
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
while (true) {
int n = stdIn.nextInt();
if (n == 0)
break;
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = stdIn.nextInt();
}
long max = INF;
for (int i = 0; i < n; i++) {
long sum = 0;
for (int j = i; j < n; j++) {
sum += a[j];
if (max < sum) {
max = sum;
}
}
}
System.out.println(max);
}
}
}
|
import java.util.*;
class Main {
static int INF = -10000000;
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
while (true) {
int n = stdIn.nextInt();
if (n == 0)
break;
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = stdIn.nextInt();
}
long max = INF;
for (int i = 0; i < n; i++) {
long sum = 0;
for (int j = i; j < n; j++) {
sum += a[j];
if (max < sum) {
max = sum;
}
}
}
System.out.println(max);
}
}
}
|
[["-", 8, 498, 0, 124, 49, 200, 51, 16, 31, 499], ["-", 8, 498, 0, 124, 49, 200, 51, 16, 17, 152], ["-", 8, 498, 0, 124, 49, 200, 51, 16, 12, 499], ["+", 8, 498, 0, 124, 49, 200, 51, 91, 17, 33], ["+", 8, 498, 0, 124, 49, 200, 51, 91, 439, 499]]
| 3
| 173
| 5
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
class Main {
public static void main(String[] args)
throws NumberFormatException, IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
while (true) {
int n = Integer.parseInt(in.readLine());
if (n == 0) {
break;
}
ArrayList<Long> nums = new ArrayList<Long>();
long max = 0;
long min = -100000;
nums.add(new Long(0));
for (int i = 0; i < n; i++) {
int nn = Integer.parseInt(in.readLine());
if (nn > min) {
min = nn;
}
if (nums.get(nums.size() - 1) * nn >= 0) {
long j = nums.get(nums.size() - 1) + nn;
nums.set(nums.size() - 1, j);
} else {
nums.add((long)nn);
}
}
if (nums.size() == 1 && nums.get(0) < 0) {
max = min;
} else {
if (nums.get(0) < 0) {
nums.remove(0);
}
if (nums.get(nums.size() - 1) < 0) {
nums.remove(nums.size() - 1);
}
max = nums.get(0);
for (int h = 0; h < nums.size(); h = h + 2) {
long sub = 0;
for (int i = h; i < nums.size(); i = i + 2) {
if (i < 2) {
sub = sub + nums.get(i);
} else {
sub = sub + nums.get(i) + nums.get(i - 1);
}
if (max < sub) {
max = sub;
}
}
}
}
System.out.println(max);
}
}
}
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
class Main {
public static void main(String[] args)
throws NumberFormatException, IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
while (true) {
int n = Integer.parseInt(in.readLine());
if (n == 0) {
break;
}
ArrayList<Long> nums = new ArrayList<Long>();
long max = 0;
long min = -100000;
nums.add(new Long(0));
for (int i = 0; i < n; i++) {
int nn = Integer.parseInt(in.readLine());
if (nn > min) {
min = nn;
}
if (nums.get(nums.size() - 1) * nn >= 0) {
long j = nums.get(nums.size() - 1) + nn;
nums.set(nums.size() - 1, j);
} else {
nums.add((long)nn);
}
}
if (nums.size() == 1 && nums.get(0) < 0) {
max = min;
} else {
if (nums.get(0) < 0) {
nums.remove(0);
}
if (nums.get(nums.size() - 1) < 0) {
nums.remove(nums.size() - 1);
}
max = nums.get(0);
for (int h = 0; h < nums.size(); h = h + 2) {
long sub = 0;
for (int i = h; i < nums.size(); i = i + 2) {
if (i - h < 2) {
sub = sub + nums.get(i);
} else {
sub = sub + nums.get(i) + nums.get(i - 1);
}
if (max < sub) {
max = sub;
}
}
}
}
System.out.println(max);
}
}
}
|
[["+", 0, 57, 15, 15, 0, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 15, 0, 16, 31, 16, 12, 22]]
| 3
| 441
| 2
|
import java.io.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str;
while ((str = br.readLine()) != "0") {
int n = Integer.parseInt(str);
long max = -1000000;
int[] s = new int[n + 1];
s[0] = 0;
for (int i = 0; i < n; i++) {
int m = Integer.parseInt(br.readLine());
s[i + 1] = s[i] + m;
}
for (int a = 0; a < n; a++) {
for (int b = a + 1; b <= n; b++) {
max = Math.max(max, s[b] - s[a]);
}
}
System.out.println(max);
}
}
}
|
import java.io.*;
class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str;
while (!(str = br.readLine()).equals("0")) {
int n = Integer.parseInt(str);
long max = -1000000;
int[] s = new int[n + 1];
s[0] = 0;
for (int i = 0; i < n; i++) {
int m = Integer.parseInt(br.readLine());
s[i + 1] = s[i] + m;
}
for (int a = 0; a < n; a++) {
for (int b = a + 1; b <= n; b++) {
max = Math.max(max, s[b] - s[a]);
}
}
System.out.println(max);
}
}
}
|
[["+", 8, 196, 0, 52, 15, 15, 0, 91, 17, 111], ["-", 8, 196, 0, 52, 15, 15, 0, 16, 17, 79], ["+", 0, 52, 15, 15, 0, 91, 439, 492, 0, 131], ["+", 0, 52, 15, 15, 0, 91, 439, 492, 141, 22], ["+", 15, 15, 0, 91, 439, 492, 3, 4, 0, 24], ["+", 15, 15, 0, 91, 439, 492, 3, 4, 0, 25]]
| 3
| 203
| 6
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] in;
while (true) {
int n = sc.nextInt();
if (n == 0)
break;
in = new int[n];
for (int i = 0; i < n; i++) {
in[i] = sc.nextInt();
}
System.out.println(maxSumSequence(in));
}
sc.close();
}
static long maxSumSequence(int[] args) {
long maxsum = 0;
for (int i = 0; i < args.length - 1; i++) {
for (int j = i; j < args.length; j++) {
long sum = sumSequence(args, i, j);
if (sum > maxsum) {
maxsum = sum;
}
}
}
return maxsum;
}
static long sumSequence(int[] args, int from, int to) {
long result = 0;
for (int i = from; i <= to; i++) {
result += args[i];
}
return result;
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] in;
while (true) {
int n = sc.nextInt();
if (n == 0)
break;
in = new int[n];
for (int i = 0; i < n; i++) {
in[i] = sc.nextInt();
}
System.out.println(maxSumSequence(in));
}
sc.close();
}
static long maxSumSequence(int[] args) {
long maxsum = args[0];
for (int i = 0; i < args.length; i++) {
for (int j = i; j < args.length; j++) {
long sum = sumSequence(args, i, j);
if (sum > maxsum) {
maxsum = sum;
}
}
}
return maxsum;
}
static long sumSequence(int[] args, int from, int to) {
long result = 0;
for (int i = from; i <= to; i++) {
result += args[i];
}
return result;
}
}
|
[["+", 8, 196, 0, 503, 49, 200, 51, 504, 516, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 504, 0, 70], ["+", 8, 196, 0, 503, 49, 200, 51, 504, 0, 73], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499]]
| 3
| 245
| 5
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int num = sc.nextInt();
if (num == 0)
break;
int sum = sc.nextInt();
int max = sum;
for (int i = 0; i < num; i++) {
int n = sc.nextInt();
if (sum + n < n) {
sum = n;
} else {
sum += n;
}
max = Math.max(max, sum);
}
System.out.println(max);
}
}
}
|
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int num = sc.nextInt();
if (num == 0)
break;
int sum = sc.nextInt();
int max = sum;
for (int i = 1; i < num; i++) {
int n = sc.nextInt();
if (sum + n < n) {
sum = n;
} else {
sum += n;
}
max = Math.max(max, sum);
}
System.out.println(max);
}
}
}
|
[["-", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499], ["+", 8, 196, 0, 7, 502, 503, 49, 200, 51, 499]]
| 3
| 142
| 2
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
@SuppressWarnings("resource") Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int num = sc.nextInt();
if (num == 0) {
break;
}
int sum = sc.nextInt();
int max = sum;
for (int i = 1; i < num; i++) {
int n = sc.nextInt();
if (sum + n < sum) {
sum = n;
} else {
sum = sum + n;
}
max = Math.max(max, sum);
}
System.out.println(max);
}
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
@SuppressWarnings("resource") Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int num = sc.nextInt();
if (num == 0) {
break;
}
int sum = sc.nextInt();
int max = sum;
for (int i = 1; i < num; i++) {
int n = sc.nextInt();
if (sum + n < n) {
sum = n;
} else {
sum = sum + n;
}
max = Math.max(max, sum);
}
System.out.println(max);
}
}
}
|
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 22], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 22]]
| 3
| 153
| 2
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int n = Integer.parseInt(sc.next());
int i, j, max = 0, tmp = 0;
int[] num = new int[5001];
if (n == 0) {
break;
}
for (i = 0; i < n; i++) {
num[i] = Integer.parseInt(sc.next());
}
max = num[0];
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
tmp += num[j];
if (max < tmp) {
max = tmp;
}
}
tmp = 0;
}
System.out.println(max);
}
sc.close();
}
}
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
int n = Integer.parseInt(sc.next());
int i, j, max = 0, tmp = 0;
int[] num = new int[5001];
if (n == 0) {
break;
}
for (i = 0; i < n; i++) {
num[i] = Integer.parseInt(sc.next());
}
max = num[0];
for (i = 0; i < n; i++) {
for (j = i; j < n; j++) {
tmp += num[j];
if (max < tmp) {
max = tmp;
}
}
tmp = 0;
}
System.out.println(max);
}
sc.close();
}
}
|
[["-", 0, 7, 8, 196, 0, 7, 502, 11, 12, 499], ["+", 0, 7, 8, 196, 0, 7, 502, 11, 12, 22]]
| 3
| 199
| 2
|
import java.util.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
static int n, max;
static int a[], best[];
public static void main(String[] args) {
while (read()) {
solve();
}
}
public static boolean read() {
n = sc.nextInt();
if (n == 0)
return false;
a = new int[n + 1];
best = new int[n + 1];
for (int i = 1; i < n + 1; i++) {
a[i] = sc.nextInt();
}
return true;
}
public static void solve() {
max = Integer.MIN_VALUE;
for (int i = 1; i < n; i++) {
best[i] = Math.max(a[i], a[i] + best[i - 1]);
max = Math.max(max, best[i]);
}
System.out.println(max);
}
}
|
import java.util.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
static int n, max;
static int a[], best[];
public static void main(String[] args) {
while (read()) {
solve();
}
}
public static boolean read() {
n = sc.nextInt();
if (n == 0)
return false;
a = new int[n + 1];
best = new int[n + 1];
for (int i = 1; i < n + 1; i++) {
a[i] = sc.nextInt();
}
return true;
}
public static void solve() {
max = Integer.MIN_VALUE;
for (int i = 1; i < n + 1; i++) {
best[i] = Math.max(a[i], a[i] + best[i - 1]);
max = Math.max(max, best[i]);
}
System.out.println(max);
}
}
|
[["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 72], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499]]
| 3
| 221
| 2
|
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
while (true) {
int n = sc.nextInt();
if (n == 0)
break;
System.out.println(run(n));
}
}
static long run(int n) {
long ans = -100000;
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
for (int i = 0; i < n - 1; i++) {
for (int j = i + 1; j < n; j++) {
long sum = 0;
for (int k = i; k <= j; k++) {
sum += a[k];
}
if (sum > ans)
ans = sum;
}
}
return ans;
}
}
|
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
while (true) {
int n = sc.nextInt();
if (n == 0)
break;
System.out.println(run(n));
}
}
static long run(int n) {
long ans = -100000;
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
long sum = 0;
for (int k = i; k <= j; k++) {
sum += a[k];
}
if (sum > ans)
ans = sum;
}
}
return ans;
}
}
|
[["-", 8, 196, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499], ["-", 0, 7, 502, 503, 49, 200, 51, 16, 17, 72], ["-", 0, 7, 502, 503, 49, 200, 51, 16, 12, 499]]
| 3
| 201
| 4
|
#include <stdio.h>
#include <string.h>
#define INF 1000000000
int n, a[5010], dp[5010];
int max(int a, int b) { return a > b ? a : b; }
int main(void) {
int x;
while (scanf("%d", &n) && n) {
for (x = 0; x < n; x++) {
scanf("%d", a + x);
}
memset(dp, -INF, sizeof(dp));
dp[0] = a[0];
int ans = -INF;
for (x = 1; x < n; x++) {
dp[x] = max(a[x], dp[x - 1] + a[x]);
ans = max(ans, dp[x]);
}
printf("%d\n", ans);
}
return 0;
}
|
#include <stdio.h>
#include <string.h>
#define INF 1000000000
int n, a[5010], dp[5010];
int max(int a, int b) { return a > b ? a : b; }
int main(void) {
int x;
while (scanf("%d", &n) && n) {
for (x = 0; x < n; x++) {
scanf("%d", a + x);
}
memset(dp, -INF, sizeof(dp));
dp[0] = a[0];
int ans = a[0];
for (x = 1; x < n; x++) {
dp[x] = max(a[x], dp[x - 1] + a[x]);
ans = max(ans, dp[x]);
}
printf("%d\n", ans);
}
return 0;
}
|
[["-", 8, 9, 0, 43, 49, 50, 51, 91, 17, 33], ["-", 8, 9, 0, 43, 49, 50, 51, 91, 28, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 69, 28, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 69, 0, 70], ["+", 8, 9, 0, 43, 49, 50, 51, 69, 71, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 69, 0, 73]]
| 0
| 186
| 6
|
#include <stdio.h>
int main(void) {
int n, a[5000], i, j, k;
while (1) {
scanf("%d", &n);
if (n == 0) {
break;
}
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
int ans = -100000, sum;
for (i = 1; i <= n; i++) {
for (j = 0; j <= n - i; j++) {
sum = 0;
for (k = 0; k < i; k++) {
sum += a[j + k];
if (sum < ans) {
break;
}
}
if (sum > ans) {
ans = sum;
}
}
}
printf("%d\n", ans);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int n, a[5000], i, j, k;
while (1) {
scanf("%d", &n);
if (n == 0) {
break;
}
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
int ans = -100000, sum;
for (i = 1; i <= n; i++) {
for (j = 0; j <= n - i; j++) {
sum = 0;
for (k = 0; k < i; k++) {
sum += a[j + k];
if (sum < 0) {
break;
}
}
if (sum > ans) {
ans = sum;
}
}
}
printf("%d\n", ans);
}
return 0;
}
|
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
| 0
| 179
| 2
|
#include <stdio.h>
int main(void) {
int n, sum, max, i, j, data[5005];
while (1) {
scanf("%d", &n);
if (n == 0) {
break;
}
for (i = 0; i < n; i++) {
scanf("%d", &data[i]);
}
max = data[0] + data[1];
for (i = 0; i < n - 1; i++) {
sum = 0;
for (j = i; j < n; j++) {
sum = sum + data[j];
if (max < sum) {
max = sum;
}
}
}
printf("%d\n", max);
}
return 0;
}
|
#include <stdio.h>
int main(void) {
int n, sum, max, i, j, data[5005];
while (1) {
scanf("%d", &n);
if (n == 0) {
break;
}
for (i = 0; i < n; i++) {
scanf("%d", &data[i]);
}
max = data[0] + data[1];
for (i = 0; i < n; i++) {
sum = 0;
for (j = i; j < n; j++) {
sum = sum + data[j];
if (max < sum) {
max = sum;
}
}
}
printf("%d\n", max);
}
return 0;
}
|
[["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
| 0
| 161
| 2
|
#include <stdio.h>
#define MAX 5000
int max(int a, int b) {
if (a > b)
return a;
return b;
}
int f(int a[], int n) {
int t = a[0];
int s = a[0];
for (int k = 1; k < n; k++)
t = max(t + a[k], a[k]);
s = max(s, t);
return s;
}
int main() {
int n, i, j;
int A[MAX];
int ans;
while (1) {
scanf("%d", &n);
if (n == 0)
break;
for (i = 0; i < n; i++) {
scanf("%d", &A[i]);
}
ans = f(A, n);
printf("%d\n", ans);
}
return 0;
}
|
#include <stdio.h>
#define MAX 5000
int max(int a, int b) {
if (a > b)
return a;
return b;
}
int f(int a[], int n) {
int t = a[0];
int s = a[0];
for (int k = 1; k < n; k++) {
t = max(t + a[k], a[k]);
s = max(s, t);
}
return s;
}
int main() {
int n, i, j;
int A[MAX];
int ans;
while (1) {
scanf("%d", &n);
if (n == 0)
break;
for (i = 0; i < n; i++) {
scanf("%d", &A[i]);
}
ans = f(A, n);
printf("%d\n", ans);
}
return 0;
}
|
[["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]]
| 0
| 196
| 34
|
#include <limits.h>
#include <stdio.h>
int main(void) {
int i, j, k;
int n, pre, max;
while (1) {
scanf("%d", &n);
if (n == 0)
break;
int x[n];
for (i = 0; i < n; i++)
scanf("%d", &x[i]);
max = INT_MIN;
for (k = 1; k <= n; k++) {
for (i = 0, pre = 0; i < k; i++)
pre += x[i];
if (max < pre)
max = pre;
for (j = 1; j < n - k; j++) {
pre = pre - x[j - 1] + x[k + j - 1];
if (max < pre)
max = pre;
}
}
printf("%d\n", max);
}
}
|
#include <limits.h>
#include <stdio.h>
int main(void) {
int i, j, k;
int n, pre, max;
while (1) {
scanf("%d", &n);
if (n == 0)
break;
int x[n];
for (i = 0; i < n; i++)
scanf("%d", &x[i]);
max = INT_MIN;
for (k = 1; k <= n; k++) {
for (i = 0, pre = 0; i < k; i++)
pre += x[i];
if (max < pre)
max = pre;
for (j = 1; j <= n - k; j++) {
pre = pre - x[j - 1] + x[k + j - 1];
if (max < pre)
max = pre;
}
}
printf("%d\n", max);
}
}
|
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
| 0
| 191
| 2
|
// AOJ Volume 0 Problem 0022
#include <stdio.h>
int aoj0022(int n) {
int i;
int a[5000];
int sum_all;
int sum_rear;
int max_front;
int max_rear;
int index_max_front;
int index_max_rear;
scanf("%d", &a[0]);
sum_all = max_front = a[0];
index_max_front = 0;
for (i = 1; i < n; i++) {
scanf("%d", &a[i]);
sum_all += a[i];
if (max_front < sum_all) {
max_front = sum_all;
index_max_front = i;
}
}
sum_rear = 0;
max_rear = a[n - 1];
index_max_rear = n - 1;
for (i = n - 1; i >= 0; i--) {
sum_rear += a[i];
if (max_rear < sum_rear) {
max_rear = sum_rear;
index_max_rear;
}
}
// printf("%d->%d %d->%d\n", max_front, index_max_front, max_rear,
//index_max_rear);
if (index_max_rear <= index_max_front) {
return (max_rear + max_front - sum_all);
}
if (max_front > max_rear) {
return (max_front);
}
return (max_rear);
}
int main(void) {
int n;
while (1) {
scanf("%d", &n);
if (n == 0) {
break;
}
printf("%d\n", aoj0022(n));
}
return (0);
}
|
// AOJ Volume 0 Problem 0022
#include <stdio.h>
int aoj0022(int n) {
int i;
int a[5000];
int sum_all;
int sum_rear;
int max_front;
int max_rear;
int index_max_front;
int index_max_rear;
scanf("%d", &a[0]);
sum_all = max_front = a[0];
index_max_front = 0;
for (i = 1; i < n; i++) {
scanf("%d", &a[i]);
sum_all += a[i];
if (max_front < sum_all) {
max_front = sum_all;
index_max_front = i;
}
}
sum_rear = 0;
max_rear = a[n - 1];
index_max_rear = n - 1;
for (i = n - 1; i >= 0; i--) {
sum_rear += a[i];
if (max_rear < sum_rear) {
max_rear = sum_rear;
index_max_rear = i;
}
}
// printf("%d->%d %d->%d\n", max_front, index_max_front, max_rear,
//index_max_rear);
if (index_max_rear <= index_max_front) {
return (max_rear + max_front - sum_all);
}
if (max_front > max_rear) {
return (max_front);
}
return (max_rear);
}
int main(void) {
int n;
while (1) {
scanf("%d", &n);
if (n == 0) {
break;
}
printf("%d\n", aoj0022(n));
}
return (0);
}
|
[["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 22]]
| 0
| 263
| 2
|
#include <stdio.h>
int main() {
int si, i, j, n, sq[5000], m, prev, sum, max, k;
do {
scanf("%d", &n);
if (!n)
break;
for (si = 0, i = 0, prev = 2, sq[0] = 0, j = 0; i < n; i++) {
scanf("%d", &m);
if (prev * m >= 0) {
if (prev == 2)
prev = 1;
sq[si] += m;
} else {
if (prev != 2) {
si++;
sq[si] = m;
prev *= -1;
}
}
if (prev == 2) {
if (j == 0 || m > j) {
j = m;
}
}
}
if (prev == 2) {
printf("%d\n", j);
continue;
}
if (sq[si] < 0)
si--;
n = si + 1;
for (sum = 0, i = 0; i < n; i++) {
sum += sq[i];
}
max = sum;
for (i = n - 2; i > 0; i -= 2) {
for (j = 0; j < ((n - i) / 2 + 1); j += 2) {
for (k = 0, sum = 0; k < i; k++) {
sum += sq[k + j];
}
if (sum > max)
max = sum;
}
}
printf("%d\n", max);
} while (1);
return 0;
}
|
#include <stdio.h>
int main() {
int si, i, j, n, sq[5000], m, prev, sum, max, k;
do {
scanf("%d", &n);
if (!n)
break;
for (si = 0, i = 0, prev = 2, sq[0] = 0, j = 0; i < n; i++) {
scanf("%d", &m);
if (prev * m >= 0) {
if (prev == 2)
prev = 1;
sq[si] += m;
} else {
if (prev != 2) {
si++;
sq[si] = m;
prev *= -1;
}
}
if (prev == 2) {
if (j == 0 || m > j) {
j = m;
}
}
}
if (prev == 2) {
printf("%d\n", j);
continue;
}
if (sq[si] < 0)
si--;
n = si + 1;
for (sum = 0, i = 0; i < n; i++) {
sum += sq[i];
}
max = sum;
for (i = n - 2; i > 0; i -= 2) {
for (j = 0; j < ((n - i) / 2 + 1); j++) {
for (k = 0, sum = 0; k < i; k++) {
sum += sq[k + j * 2];
}
if (sum > max)
max = sum;
}
}
printf("%d\n", max);
} while (1);
return 0;
}
|
[["-", 0, 7, 8, 9, 0, 7, 26, 11, 17, 107], ["-", 0, 7, 8, 9, 0, 7, 26, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 26, 27, 17, 29], ["+", 0, 11, 12, 69, 71, 16, 12, 16, 17, 48], ["+", 0, 11, 12, 69, 71, 16, 12, 16, 12, 13]]
| 0
| 340
| 5
|
#include <limits.h>
#include <stdio.h>
#define DEBUG 0
int buf[5001];
/*
100kx5k= 500M
2^20 = 1M
*/
int find_max_sum(int count) {
int i, j;
int max, s;
int sum;
max = INT_MIN;
for (i = 0; i < count; i++) {
s = 0;
for (j = i; j <= count; j++) {
s += buf[j];
if (s >= max)
max = s;
}
}
return max;
}
int main() {
int count;
int i;
while ((scanf("%i", &count) == 1) && count) {
if (DEBUG)
printf("count: %d\n", count);
for (i = 0; i < count; i++) {
scanf("%i", buf + i);
if (DEBUG)
printf("data: %d\n", *(buf + i));
}
printf("%d\n", find_max_sum(count));
}
return 0;
}
|
#include <limits.h>
#include <stdio.h>
#define DEBUG 0
int buf[5001];
/*
100kx5k= 500M
2^20 = 1M
*/
int find_max_sum(int count) {
int i, j;
int max, s;
int sum;
max = INT_MIN;
for (i = 0; i < count; i++) {
s = 0;
for (j = i; j < count; j++) {
s += buf[j];
if (s >= max)
max = s;
}
}
return max;
}
int main() {
int count;
int i;
while ((scanf("%i", &count) == 1) && count) {
if (DEBUG)
printf("count: %d\n", count);
for (i = 0; i < count; i++) {
scanf("%i", buf + i);
if (DEBUG)
printf("data: %d\n", *(buf + i));
}
printf("%d\n", find_max_sum(count));
}
return 0;
}
|
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18]]
| 0
| 200
| 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.