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 ...
随机推荐
- varnish缓存安装使用
varnish PDF http://files.cnblogs.com/jimingsong/varnish.pdf 目前介绍CentOS6.4-64位系统 yum安装varnish: 配置varn ...
- Angularjs中的ng-class
在angular中为我们提供了3种方案处理class:1:scope变量绑定.(不推荐使用)2:字符串数组形式.3:对象key/value处理. 我们继续其他两种解决方案:1字符串数组形式是针对cla ...
- Html:upload
文件上传框 有时候,需要用户上传自己的文件,文件上传框看上去和其它 文本域差不多,只是它还包含了一个浏览按钮.访问者可以通 过输入需要上传的文件的路径或者点击浏览按钮选择需要上传 的文件. 代码格式: ...
- Concepts and Tricks In CNN
转自:http://blog.cvmarcher.com/posts/2015/05/17/cnn-trick/ 这篇文章主要讲一下Convolutional Neural Network(CNN)里 ...
- Qt Quick 简单教程
上一篇<Qt Quick 之 Hello World 图文详解>我们已经分别在电脑和 Android 手机上运行了第一个 Qt Quick 示例—— HelloQtQuickApp ,这篇 ...
- VB 要求对象
vDoc = WebBrowser1.Document '提示要求对象 Set vDoc = WebBrowser1.Document '正确执行
- javascript IP验证
//IP验证function isIP(strIP){try{if(strIP.length<7){return false;}var re=/^(\d+)\.(\d+)\.(\d+)\.(\d ...
- 关于spring的注解方式注入默认值(转) -- 首字母小写
1.是首字母小写 比如 UserAction对应的id是userAction 可以通过ApplicationContext 对象的act.getBean("userAction") ...
- 网站网址前的小logo
认识网页前小图标 1.能在浏览器标签.地址栏左边和收藏夹栏显示小图标的网站,其网站都是使用了其名称为"favicon.ico"图标文件,格式为ico格式,图标大小一般为16*16, ...
- Beam me out!
Beam me out! 题目描述 King Remark, first of his name, is a benign ruler and every wrongdoer gets a second ...