暴力

#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. jsp第1讲(上集)

    jsp讲解框架 (一)Java EE核心十三种技术介绍 (二)Java EE程序员修炼成精的法门 (三)jsp版本的用户管理系统演示 (四)jsp概述 (五)jsp的运行原理 (六)jsp版的计算器 ...

  2. 【伪一周小结(没错我一周就做了这么点微小的工作)】HDOJ-1241 Oil Deposits 初次AC粗糙版对比代码框架重构版

    2016 11月最后一周 这一周复习了一下目前大概了解的唯一算法--深度优先搜索算法(DFS).关于各种细节的处理还是极为不熟练,根据题意判断是否还原标记也无法轻松得出结论.不得不说,距离一个准ACM ...

  3. Ckeditor配置

    配置参考文档,主要将ckeditor中的(adapters.images.lang.plugins.skins.themes.ckeditor.js.config.js.contents.css)解压 ...

  4. freemarker中的list 前端模板

    freemarker list (长度,遍历,下标,嵌套,排序)1. freemarker获取list的size : JavaArrayList<String> list = new Ar ...

  5. asp.net控件ControlToValidate同OnClientClick冲突解决办法

    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Error ...

  6. 获取输入设备的vid和pid

    一.获取/dev/input/event16设备的vid和pid testhid.c #include <linux/types.h> #include <linux/input.h ...

  7. nuget pack 时不包含依赖包(而不是引用项目的dll,区别于IncludeReferencedProjects)

    Excluding development dependencies when creating packages Some NuGet packages are useful as developm ...

  8. HTTPclient cookie的获取与设置

    因为代码与Java用apache的HttpClient发送Post请求大部份重复,所以就不贴整段代码了,只把不同的地方贴出来.发送Cookie就必须先得到Cookie,所以至少发送两次请求,第一次用于 ...

  9. 【dp】 poj 1157

    不错的dp入门题  画出dp矩阵  每个dp[i][j]是由“其上”的状态或是“其左上”的状态转化而来,那我们选对角线和上边进行三角dp推导 #include<stdio.h> #incl ...

  10. Template - Strategy

    模板模式是一种基于继承的松耦合模式,其设计思路为,abstract类提供一组接口但不实现,不同concrete类继承同一接口并完成不同功能.如下图所示: 模板模式实现较为简单,TemplateMeth ...