250

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std; struct Pair {
int val, p;
Pair() {
}
Pair(int _, int __) {
val = _, p = __;
}
bool operator < (Pair o) const {
return val < o.val;
}
};
class HungryCowsEasy {
public:
vector<int> findFood(vector<int> A, vector<int> C) {
vector<int> Res;
vector<Pair> B;
for (int i = 0; i < C.size(); i += 1) {
B.push_back(Pair(C[i], i));
}
stable_sort(B.begin(), B.end());
for (int i = 0; i < A.size(); i += 1) {
int p = lower_bound(B.begin(), B.end(), Pair(A[i], 0)) - B.begin();
if (p < 0) Res.push_back(0);
else if (p > 0 and abs(A[i] - B[p - 1].val) <= abs(A[i] - B[p].val))
Res.push_back(B[p - 1].p);
else if (p < B.size() - 1 and abs(B[p + 1].val - A[i]) < abs(A[i] - B[p].val))
Res.push_back(B[p + 1].p);
else Res.push_back(B[p].p);
}
return Res;
}
};

第二题

#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cctype>
#include<string>
using namespace std; class ForumPostMedium{
public:
string ans[3];
ForumPostMedium() {
ans[0] = "few seconds ago";
ans[1] = " minutes ago";
ans[2] = " hours ago";
}
int getid(char a,char b) {
return (a - '0') * 10 + (b - '0');
}
string getShownPostTime(string t, string s) {
int a[5], b[5];
a[1] = getid(s[0], s[1]); a[2] = getid(s[3], s[4]); a[3] = getid(s[6], s[7]);
b[1] = getid(t[0], t[1]); b[2] = getid(t[3], t[4]); b[3] = getid(t[6], t[7]);
LL l = a[1] * 3600 + a[2] * 60 + a[3];
LL r = b[1] * 3600 + b[2] * 60 + b[3];
LL x = r - l;
if (x < 0) x += 86400;
if (x < 60) return ans[0];
else if (x < 3600) return ttoo(x / 60) + ans[1];
else return to_string(x / 3600) + ans[2];
}
};

SRM 739 Div.2的更多相关文章

  1. Topcoder口胡记 SRM 562 Div 1 ~ SRM 599 Div 1

    据说做TC题有助于提高知识水平? :) 传送门:https://284914869.github.io/AEoj/index.html 转载请注明链接:http://www.cnblogs.com/B ...

  2. TopCoder SRM 560 Div 1 - Problem 1000 BoundedOptimization & Codeforces 839 E

    传送门:https://284914869.github.io/AEoj/560.html 题目简述: 定义"项"为两个不同变量相乘. 求一个由多个不同"项"相 ...

  3. 竞赛图的得分序列 (SRM 717 div 1 250)

    SRM 717 DIV 1 中 出了这样一道题: 竞赛图就是把一个无向完全图的边定向后得到的有向图,得分序列就是每个点的出度构成的序列. 给出一个合法的竞赛图出度序列, 要求构造出原图(原题是求(u, ...

  4. TopCoder SRM 667 Div.2题解

    概览: T1 枚举 T2 状压DP T3 DP TopCoder SRM 667 Div.2 T1 解题思路 由于数据范围很小,所以直接枚举所有点,判断是否可行.时间复杂度O(δX × δY),空间复 ...

  5. 刷题记录:Codeforces Round #739 (Div. 3)

    Codeforces Round #739 (Div. 3) 20210907.网址:https://codeforces.com/contest/1560. --(叹). A 不希望出现带" ...

  6. Topcoder SRM 648 (div.2)

    第一次做TC全部通过,截图纪念一下. 终于蓝了一次,也是TC上第一次变成蓝名,下次就要做Div.1了,希望div1不要挂零..._(:зゝ∠)_ A. KitayutaMart2 万年不变的水题. # ...

  7. SRM 638 Div.2

    250 给一个字符串 要求从一种形式换成另一形式 class NamingConvention{ private: int a, b, c; public: int d; string toCamel ...

  8. [topcoder]SRM 646 DIV 2

    第一题:K等于1或者2,非常简单.略.K更多的情况,http://www.cnblogs.com/lautsie/p/4242975.html,值得思考. 第二题:http://www.cnblogs ...

  9. [topcoder]SRM 633 DIV 2

    第一题,http://community.topcoder.com/stat?c=problem_statement&pm=13462&rd=16076 模拟就可以了. #includ ...

随机推荐

  1. BZOJ4566:[HAOI2016]找相同字符——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=4566 https://www.luogu.org/problemnew/show/P3181 给定 ...

  2. BZOJ2152:聪聪可可——题解

    http://www.lydsy.com/JudgeOnline/problem.php?id=2152 Description 聪聪和可可是兄弟俩,他们俩经常为了一些琐事打起来,例如家中只剩下最后一 ...

  3. 【BZOJ 4455】 [Zjoi2016]小星星 容斥计数

    dalao教导我们,看到计数想容斥……卡常策略:枚举顺序.除去无效状态.(树结构) #include <cstdio> #include <cstring> #include ...

  4. 【DP】【P1586】四方定理

    传送门 Description Input 第一行为一个整数T代表数据组数,之后T行每行一个数n代表要被分解的数 Output 对于每个n输出一行,为方案个数 Sample Input Sample ...

  5. Linux环境下用Weblogic发布项目【二】 -- 配置Domain域

    配置注意事项: 修改密码时密码长度最少8位:在"<下一步>"后面为空即表示敲回车: 具体配置步骤如下: [root@GPS-App ~]# [root@GPS-App ...

  6. hdu 5625

    Clarke and chemistry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

  7. mapper中的CDATA标签的用法

    术语 CDATA 指的是不应由 XML 解析器进行解析的文本数据(Unparsed Character Data). 在 XML 元素中,"<" 和 "&& ...

  8. JQuery学习五

    获取样式attr("myclass")移除样式removeClass("myclass")增加样式addClass("myclass")to ...

  9. json 拼二维json数组

    js声明数组 以及向数组中添加as移除json数据 JavaScript声明JSON数组的方法: //部分条件,在数据渲上数据要求是数组格式而非json数组格式,取arrayJson.dataList ...

  10. Java中JAVA_HOME与CLASSPATH的解析(转)

    很多人在初学Java的时候经常会被书中介绍的一堆环境变量的设置搞得头昏脑胀,很多书中都会在初装JDK的时候让他大家设置JAVA_HOME环境变量,在开发程序的时候设置CLASSPATH环境变量,而很多 ...