比赛 2024暑假C班集训8 评测结果 AAAAAAAAAA
题目名称 吉他 最终得分 100
用户昵称 彭欣越 运行时间 0.782 s
代码语言 C++ 内存使用 2.87 MiB
提交时间 2024-07-08 11:20:58
显示代码纯文本
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. long long n,p,res;
  4. deque<int>a[10];
  5. int main () {
  6. freopen("gitara.in","r",stdin);
  7. freopen("gitara.out","w",stdout);
  8. cin >> n >> p;
  9. for (int i=1;i<=n;i++) {
  10. int x,y;
  11. cin >> x >> y;
  12. while (a[x].size()&&a[x].back()>y) {
  13. res++;
  14. a[x].pop_back();
  15. }
  16. if (a[x].size()==0||a[x].back()!=y) {
  17. a[x].push_back(y);
  18. res++;
  19. }
  20. }
  21. cout << res <<endl;
  22. return 0;
  23. }