codeforces 665B Shopping
暴力
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
using namespace std; int n,m,k;
int a[],b[]; int pos(int num)
{
for(int i=;i<=k;i++)
if(a[i]==num) return i;
} void update(int num)
{
int z=;
b[]=num;
for(int i=;i<=k;i++)
{
if(a[i]==num) continue;
b[z++]=a[i];
}
for(int i=;i<=k;i++) a[i]=b[i];
} int main()
{
scanf("%d%d%d",&n,&m,&k);
for(int i=;i<=k;i++) scanf("%d",&a[i]);
int ans=;
for(int i=;i<=n;i++)
{
for(int j=;j<=m;j++)
{
int num; scanf("%d",&num); ans=ans+pos(num);
update(num);
}
}
printf("%d\n",ans);
return ;
}
codeforces 665B Shopping的更多相关文章
- codeforces 665B B. Shopping(水题)
题目链接: B. Shopping time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- CodeForces 665B 【水-暴力】
题意(来自网络): 现在有k件商品,每个商品的位置已经告诉你了 现在有n个人,每个人有m个需求,每个需求就是要把第a[i][j]个物品拿到第一个位置来 他的代价是pos[a[i][j]] 问你所有代价 ...
- Codeforces Gym 100803C Shopping 贪心
Shopping 题目连接: http://codeforces.com/gym/100803/attachments Description Your friend will enjoy shopp ...
- Codeforces Round #332 (Div. 2) A. Patrick and Shopping 水题
A. Patrick and Shopping Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...
- Educational Codeforces Round 12 B. Shopping 暴力
B. Shopping 题目连接: http://www.codeforces.com/contest/665/problem/B Description Ayush is a cashier at ...
- codeforces#1139F. Dish Shopping (离散化数组数组+ 扫描线)
膜拜大佬:https://blog.csdn.net/xyz32768/article/details/88831233 题目链接: http://codeforces.com/contest/113 ...
- Codeforces 1139F Dish Shopping 树状数组套平衡树 || 平衡树
Dish Shopping 将每个物品拆成p 和 s 再加上人排序. 然后问题就变成了, 对于一个线段(L - R), 问有多少个(li, ri)满足 L >= li && R ...
- Educational Codeforces Round 47 (Rated for Div. 2) :A. Game Shopping
题目链接:http://codeforces.com/contest/1009/problem/A 解题心得: 题意就是给你两个数列c,a,你需要从c中选择一个子串从a头开始匹配,要求子串中的连续的前 ...
- Codeforces Round #332 (Div. 2)A. Patrick and Shopping 水
A. Patrick and Shopping Today Patrick waits for a visit from his friend Spongebob. To prepare for ...
随机推荐
- TCP/IP体系结构-测试人员必须理解的
如果还想在测试这条路上继续走下去的话,那么下面这些东西就是我们必须去掌握的,至少你还不想止步于简单的黑盒测试--其实,一直想去接触Linux下的应用测试,这样能学到东西会很多,而且会非常的受用.之前听 ...
- hdu_4547_CD操作(在线LCA)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4547 题意:中文,不解释 题解:很裸的LCA,注意父目录打开子目录一次就够了,这里我才用倍增在线LCA ...
- uCGUI的文字与数值显示方法
uCGUI的数值显示非常的灵活方便,是制作LCD界面非常好的选择. 文字与数值显示的方法: 常用文本显示函数: void GUI_DispStringAt(const char GUI_FAR *s, ...
- 批量删除实现js+springmvc
前台的控件 <input type='checkbox' name='isSelect' value='"+data[i].id+"' ></input>& ...
- vs调试有时能进去后台,有时不能进去
前两天做项目时,遇到调试时有时候能进后台,有时候直接就弹出运行结果,反复查找原因,最后发现,原来是页面输出缓存的原因,我在web页面用到了< OutputCache Duration=" ...
- linq any() all() 返回true 或者false
一.any()只要有一个符合条件就返回true static void Main(string[] args) { //any 有符合条件的就返回true ,,,,,,,,,}; ); Console ...
- 【Tomcat】Tomcat配置之请求字符串编码
默认情况下,如果tomcat中部署的webservice或者web网站需要有中文的请求参数,而这时候我们直接在浏览器中输入中文那么接受到的将是乱码,无法达到我们的需求,这时候我们就需要对Tomcat的 ...
- HDU2050 由直线分割平面推广到折线分割平面
直线分割平面问题: 加入已有n-1条直线,那么再增加一条直线,最多增加多少个平面? 为了使增加的平面尽可能的多,我们应该使新增加的直线与前n条直线相交,且不存在公共交点.那么我们可以将新增加的这条直线 ...
- linux视频学习4(crontab和进程)
1 . crontab定时任务: 任务调度: 系统在某个时间执行的特定的命令. 分类: 1.系统工作.2.个别的用户工作. 设置任务调度文件: /etc/crontab 1.crontab -e : ...
- php 批量导入数据的一种思维
<?php $str="风湿免疫科 消化内科 内分泌科 神经内科 感染内科 心血管内科放疗中心";$arr=explode(' ',$str);$sql="&quo ...