codeforces 890B. Vlad and Cafes
来源:互联网 发布:ubuntu 升级python2.7 编辑:程序博客网 时间:2024/06/03 08:44
题意:给你一个N表示Vlad最近去过N次咖啡馆,下面第i个数表示他倒数第N - i次去的咖啡馆的编号。问他最后一次去过哪个咖啡馆的时间最早(就是我最长时间没去过的咖啡馆是哪个)?
题意:用set插入,然后从后往前删除,直到只剩下一个元素的时候就是答案。
#include<bits/stdc++.h>using namespace std;const int MAXN = 2e5 + 5;int n,a[MAXN];int main(){while(~scanf("%d", &n)){set<int> s;for(int i = 0; i < n; i++){scanf("%d", &a[i]);s.insert(a[i]);}for(int i = n - 1; i >= 0; i--){if(s.size() == 1){printf("%d\n",*s.begin());break;}s.erase(a[i]);}} return 0;}
阅读全文
0 0
- codeforces 890B. Vlad and Cafes
- CodeForces 890B Vald and Cafes
- VLAD
- VLAD
- VLAD
- codeforces B. Ciel and Duel
- codeforces B. Sereja and Contests
- codeforces B. Jzzhu and Sequences
- 【CODEFORCES】 B. Pashmak and Flowers
- 【CODEFORCES】 B. Caisa and Pylons
- codeforces B. Pasha and String
- 【CODEFORCES】 B. Dreamoon and WiFi
- 【CODEFORCES】 B. Dreamoon and Sets
- 【CODEFORCES】 B. Friends and Presents
- codeforces B. Mishka and trip
- codeforces B. Memory and Trident
- Codeforces B. Coupons and Discounts
- codeforces B. Mike and strings
- 自动化学习记录问题1
- web前端安全
- Altium Designer 16相关入门教程
- 算法 (排序乐园Lv-2) 插入排序代码实现
- python抽象类、抽象方法的实现
- codeforces 890B. Vlad and Cafes
- 字符串编码解码的一点理解
- knn代码
- node.js那些事
- X64 SEH的展开
- 如何写高质量代码?
- 双向绑定伪代码
- 静态顺序表的一些操作
- Java| Java关键字-static,final比较