Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
124006 柯昊阳 选择客栈 C++ 通过 100 7 MS 1828 KB 1272 2024-01-23 10:37:51

Tests(10/10):


#include<bits/stdc++.h> using namespace std; const int maxn = 2000086; struct enkidu { int color, cost; }a[maxn]; int n, k, p; int color_cnt[60], color_last[60]; int color_num[60]; int last_acc; int ans = 0; bool vis[maxn]; inline int read() { int x = 0, y = 1; char ch = getchar(); while(!isdigit(ch)) { if(ch == '-') y = -1; ch = getchar(); } while(isdigit(ch)) { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); } return x * y; } int main() { memset(color_cnt, 0, sizeof(color_cnt)); memset(color_num, 0, sizeof(color_num)); n = read(), k = read(), p = read(); for(int i = 1; i <= n; ++i) a[i].color = read(), a[i].cost = read(); for(int i = 1; i <= n; ++i) { int cl = a[i].color; if(a[i].cost <= p) last_acc = i; if(vis[cl]) { if(color_last[cl] <= last_acc) color_num[cl] = color_cnt[cl]; color_last[cl] = i; ans += color_num[cl]; color_cnt[cl]++; } else if(!vis[cl]) { color_last[cl] = i; color_cnt[cl]++; vis[cl] = 1; } } cout << ans << '\n'; return 0; }


测评信息: