原题链接

D. Magic Box
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

One day Vasya was going home when he saw a box lying on the road. The box can be represented as a rectangular parallelepiped. Vasya needed no time to realize that the box is special, as all its edges are parallel to the coordinate axes, one of its vertices is at point(0, 0, 0), and the opposite one is at point (x1, y1, z1). The six faces of the box contain some numbers a1, a2, ..., a6, exactly one number right in the center of each face.

The numbers are located on the box like that:

  • number a1 is written on the face that lies on the ZOX plane;
  • a2 is written on the face, parallel to the plane from the previous point;
  • a3 is written on the face that lies on the XOY plane;
  • a4 is written on the face, parallel to the plane from the previous point;
  • a5 is written on the face that lies on the YOZ plane;
  • a6 is written on the face, parallel to the plane from the previous point.

At the moment Vasya is looking at the box from point (x, y, z). Find the sum of numbers that Vasya sees. Note that all faces of the box are not transparent and Vasya can't see the numbers through the box. The picture contains transparent faces just to make it easier to perceive. You can consider that if Vasya is looking from point, lying on the plane of some face, than he can not see the number that is written on this face. It is enough to see the center of a face to see the corresponding number for Vasya. Also note that Vasya always reads correctly the ai numbers that he sees, independently of their rotation, angle and other factors (that is, for example, if Vasya sees some ai = 6, then he can't mistake this number for 9 and so on).

Input

The fist input line contains three space-separated integers xy and z (|x|, |y|, |z| ≤ 106) — the coordinates of Vasya's position in space. The second line contains three space-separated integers x1, y1, z1 (1 ≤ x1, y1, z1 ≤ 106) — the coordinates of the box's vertex that is opposite to the vertex at point (0, 0, 0). The third line contains six space-separated integers a1, a2, ..., a6 (1 ≤ ai ≤ 106) — the numbers that are written on the box faces.

It is guaranteed that point (x, y, z) is located strictly outside the box.

Output

Print a single integer — the sum of all numbers on the box faces that Vasya sees.

Examples
input
2 2 2
1 1 1
1 2 3 4 5 6

output
12

input
0 0 10
3 2 3
1 2 3 4 5 6

output
4

Note

The first sample corresponds to perspective, depicted on the picture. Vasya sees numbers a2 (on the top face that is the darkest), a6(on the right face that is the lightest) and a4 (on the left visible face).

In the second sample Vasya can only see number a4.

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>using namespace std;
typedef long long ll;int main(){//   freopen("in.txt", "r", stdin);int a[7];int x, y, z, x1, y1, z1;scanf("%d%d%d%d%d%d", &x, &y, &z, &x1, &y1, &z1);for(int i = 1; i <= 6; i++)scanf("%d", a+i);int s = 0;if(y > y1)s += a[2];if(y < 0)s += a[1];if(z > z1)s += a[4];if(z < 0)s += a[3];if(x > x1)s += a[6];if(x < 0)s += a[5];cout << s << endl;return 0;
} 

Codeforces Round #143 (Div. 2)-D. Magic Box相关推荐

  1. Codeforces Round #143 (Div. 2) (ABCD 思维场)

    题目连链接:http://codeforces.com/contest/231 A. Team time limit per test:2 seconds memory limit per test: ...

  2. codeforces水题100道 第十一题 Codeforces Round #143 (Div. 2) A. Team (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/231/A 题意:问n道题目当中有多少道题目是至少两个人会的. C++代码: #include &l ...

  3. Codeforces Round #143 (Div. 2) C

    http://codeforces.com/contest/231/problem/C 昨天的cf.比赛的时候其实有点思路的,但是因为B搞错方向了没敢写C.刚刚写了下,AC了.用的思路还真是昨天晚上的 ...

  4. Codeforces Round #143 (Div. 2) C. To Add or Not to Add 胡搞

    A piece of paper contains an array of n integers a1, a2, ..., an. Your task is to find a number that ...

  5. Codeforces Round 867 (Div. 3) G2. Magic Triples (Hard Version)

    题意是多少对 互不相同的下标i,j,k满足对应数等比 很自然的想到了枚举最大数,然后找到因子就做完了 1e9以内因子最多1e3,这个不难发现,知道怎么通过质因数分解得到因子个数就知道怎么算了. 毫无优 ...

  6. Codeforces Round #635 (Div. 1) C. Kaavi and Magic Spell 区间dp

    传送门 文章目录 题意: 思路: 题意: 给你两个串s,ts,ts,t,每次都可以从sss的开头拿一个字符放到AAA串的开头或结尾,问最终有多少种方案使得ttt是AAA的前缀,注意sss不必全部拿完. ...

  7. Codeforces Round #516 (Div. 2Div.1)

    Codeforces Round #516 (Div. 2&&Div.1) (Div.1) 题号 题目 知识点 A Make a triangle! 贪心题 B Equations o ...

  8. CodeCraft-21 and Codeforces Round #711 (Div. 2)

    CodeCraft-21 and Codeforces Round #711 (Div. 2) 题号 题目 考点 A GCD Sum 签到,模拟 B Box Fitting 贪心 C Planar R ...

  9. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

最新文章

  1. WPF TabControl Unload俩次的解决方案
  2. vb 实现小超市饮料补货提醒程序 public全局变量的声明与初始化
  3. 大型ERP等数据库系统常见几种设计------(转)
  4. 约瑟夫(环)问题(Josephu)(单向环形链表)
  5. 怎么改字段名称_精装房这么改!换门框,封阳台,效果出来比毛坯房还好
  6. SQLServer链接服务器至Oracle
  7. 面试官 | 如何在 Spring Boot 中进行参数校验?
  8. win2k,XP下用setupapi.dll自动安装Driver
  9. React-Native集成dva.js
  10. php 控制海康摄像头,通过ISAPI http协议控制海康摄像头
  11. 微信小程序实现登录Java前后端分离
  12. STM32的ETR引脚计数功能
  13. Win10系统提示过期,三条命令帮你搞定
  14. 207最新android书籍,《最强Android书 架构大剖析》PDF(高清版)
  15. 社交电商跟传统电商有什么区别?近来发展得如何?
  16. jenkins + jmeter +ant 发送邮件失败
  17. 每日分享之《生命树》
  18. precision and recall
  19. VBS带你领略脚本语言的快乐!(基础篇)
  20. 重识Nginx - 系列导读

热门文章

  1. 两个苹果手机怎么定位_苹果手机怎么截屏?
  2. python报错:使用lgb过程中报错:DataFrame.dtypes for data must be int, float or bool
  3. 持续使用KimJongRAT和PCRat发动攻击:BabyShark恶意软件分析
  4. 面试js数组和object string点滴yan
  5. flutter 记录 问题
  6. 有营养的废话:人工智能、大数据和高性能计算融合成为趋势丨AI推理服务器,能读懂福尔摩斯?【软件网每日新闻播报│第10-24期】
  7. 账号联合运营--花漾指纹浏览器引领跨境电商新趋势
  8. Cg Programming/Unity/Lighting Textured Surfaces光照纹理表面
  9. 中国地质大学计算机学院保研率,北京高校保研率、考研率排行榜
  10. 【毅力挑战】PCIe 每日一问一答(2022.12 已归档)