暴力

#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的更多相关文章

  1. codeforces 665B B. Shopping(水题)

    题目链接: B. Shopping time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  2. CodeForces 665B 【水-暴力】

    题意(来自网络): 现在有k件商品,每个商品的位置已经告诉你了 现在有n个人,每个人有m个需求,每个需求就是要把第a[i][j]个物品拿到第一个位置来 他的代价是pos[a[i][j]] 问你所有代价 ...

  3. Codeforces Gym 100803C Shopping 贪心

    Shopping 题目连接: http://codeforces.com/gym/100803/attachments Description Your friend will enjoy shopp ...

  4. 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 ...

  5. Educational Codeforces Round 12 B. Shopping 暴力

    B. Shopping 题目连接: http://www.codeforces.com/contest/665/problem/B Description Ayush is a cashier at ...

  6. codeforces#1139F. Dish Shopping (离散化数组数组+ 扫描线)

    膜拜大佬:https://blog.csdn.net/xyz32768/article/details/88831233 题目链接: http://codeforces.com/contest/113 ...

  7. Codeforces 1139F Dish Shopping 树状数组套平衡树 || 平衡树

    Dish Shopping 将每个物品拆成p 和 s 再加上人排序. 然后问题就变成了, 对于一个线段(L - R), 问有多少个(li, ri)满足  L >= li && R ...

  8. Educational Codeforces Round 47 (Rated for Div. 2) :A. Game Shopping

    题目链接:http://codeforces.com/contest/1009/problem/A 解题心得: 题意就是给你两个数列c,a,你需要从c中选择一个子串从a头开始匹配,要求子串中的连续的前 ...

  9. 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 ...

随机推荐

  1. Chapter 1 First Sight——31

    I took notes carefully anyway, always looking down. 不论怎么样我都仔细的记着笔记,一直低着头. I couldn't stop myself fro ...

  2. java中的静态变量

    大家都知道,我们可以基于一个类创建多个该类的对象,每个对象都拥有自己的成员,互相独立.然而在某些时候,我们更希望该类所有的对象共享同一个成员.此时就是 static 大显身手的时候了!! Java 中 ...

  3. Entity Framework技巧系列之八 - Tip 29 – 34

    提示29. 怎样避免延迟加载或Load()阅读器问题 如果你有如下这样的代码: 1 var results = from c in ctx.Customers 2 where c.SalesPerso ...

  4. swap in java?

    Is it possible to write a swap method in java? these two variables will be primitives. It's not poss ...

  5. cdn是什么

    CDN的全称是Content Delivery Network,即内容分发网络.其目的是通过在现有的Internet中增加一层新的网络架构, 将网站的内容发布到最接近用户的网络”边缘”,使用户可以就近 ...

  6. hover带有动画效果的导航

    html,body{overflow-x:hidden;} ul,li{list-style: none;} .nav{width:100%; height: 26px; overflow: hidd ...

  7. 非常简单的oracle和mysql数据互传

    工具是navicat,我用的是Navicat Premium 10: 这个工具可以同时连接mysql和oracle,如图: 同时连接上这两个库之后 工具->数据传输 左边是数据源,右边是导入目标 ...

  8. Android内核驱动程序的编写和编译过程

    注意:涉及的代码为android内核代码而不是android源码. 在智能手机时代,每个品牌的手机都有自己的个性特点.正是依靠这种与众不同的个性来吸引用户,营造品牌凝聚力和用户忠城度,典型的代表非ip ...

  9. sessionStorage用于分页,瀑布流和存储用户数据等

    在手机网页开发中,会用到分页和瀑布流来分量显示数据.这里会遇到一个问题.当点击某条数据进入详情后,再按手机的返回键会到上一个页面,该页面是重新加载的. 本人在微信里用内置的qq浏览器打开页面,wind ...

  10. 学习笔记——Windows下cocos2d-x,eclipse中自编译

    cocos2d-x创建的安卓项目导入eclipse后. 在项目属性中配置Builders. 在eclipse编译还需要配置相应的变量,即后面提到的cygwin编译中要添加的变量. D:/cygdriv ...