偏偏晚上11点开始…有点醉
果然还是只能写两题的水平。
先来一个小目标,两个月内换一个颜色啊!!!
讲道理这两题纯粹靠的手速啊。
A
根本没仔细看题意,总之就是一个形状对应几个面,给出几个形状,求面的总和。
A题好像总在卡int的范围。
下次我一定试试hack
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
using namespace std;
#define inf 0x3f3f3f3f
map<string,int> ss;
int main()
{
ss["Tetrahedron"] = 4;
ss["Cube"] = 6;
ss["Octahedron"] = 8;
ss["Dodecahedron"] = 12;
ss["Icosahedron"] = 20;
int n;
scanf("%d",&n);
long long ans = 0;
while(n--)
{
char s[20];
scanf("%s",s);
ans += ss[s];
}
cout<<ans<<endl;
return 0;
}
B
有个同学想要去上chess课,又想去program课,给出几个选择时段的可能,求中间最长能休息多久。
很明显,我们只需要知道chess课最早结束和program课最迟开始的差值, 以及chess课最迟开始和prograss最早结束的差值,取最大,如果都<=0 输出0
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
using namespace std;
#define inf 0x3f3f3f3f
#define maxn 200005
int main()
{
int n1,n2;
int a;int b;
scanf("%d",&n1);
int bmin = inf,amax = 0;
for(int i = 0; i < n1 ; i ++)
{
scanf("%d%d",&a,&b);
if(a > amax) amax = a;
if(b < bmin) bmin = b;
}
scanf("%d",&n2);
int j,k;
int kmin = inf, jmax = 0;
for(int i = 0; i < n2; i++)
{
scanf("%d%d",&j,&k);
if(j > jmax) jmax = j;
if(k < kmin) kmin = k;
}
int aa = jmax - bmin;
int bb = amax - kmin;
if(aa <= 0 && bb <= 0)
printf("%d\n",0);
else
printf("%d\n",max(aa,bb));
return 0;
}
写到第三题的时候,感觉是题数学题,但是自己就是没办法推…
想想自己的写法绝对会tle….哎
希望自己能快点能写第三题。