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 ...
随机推荐
- selenium高级用法
http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp# WebDriver: Advanced Usage Explicit and Im ...
- The 3n + 1 problem
The 3n + 1 problem Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) ...
- shell之路【第二篇】运算与文件调用
Bash 支持很多运算符,包括算数运算符.关系运算符.布尔运算符.字符串运算符和文件测试运算符. 原生bash不支持简单的数学运算,默认都是字符串操作,但是可以通过其他命令来实现 算数运算 expr. ...
- C#常用集合的使用
大多数集合都在System.Collections,System.Collections.Generic两个命名空间.其中System.Collections.Generic专门用于泛型集合. 针对特 ...
- shell命令一行代码搞定【转】
查看文件内容-while: cat 1.txt|while read line;do echo $line;done while read line; do echo $line; done < ...
- Apache开启gzip压缩传输
修改Apache配置文件 第一步,添加两个模块 LoadModule deflate_module modules/mod_deflate.so LoadModule headers_module m ...
- onPostCreate——Activity彻底运行起来之后的回调
记得之前想要在Activity布局完成,彻底跑起来之后,再获取当前Activity的窗口中,某个View的宽高,之前用的办法很土,弄个Handler,发个Message出来,使用sendMessage ...
- idea 端口占用
netstat -anp | grep 8080 lsof -i:8080 查看8080端口被什么进程占用 kill (-s 9) 12903 -s 9 强制 尽快 12903 上面查出的 PID 其 ...
- OpenGL红宝书例3.1 -- glBufferSubData使用
代码实现 1.1 C++部分 GLFWwindow *window; GLuint shader_program; GLuint VAO; void init() { static const GLf ...
- java int和Integer的区别
今天偶然和同学讨论到int和Integer的区别是,发现自己对这个问题了解的并不是很清楚,而且有些概念还是错的,所以在这对int和Integer的区别做一个总结. int与integer的区别从大的方 ...