纯粹是一道模拟题目,直接枚举60+, 剪一下枝100+.......
/*
noip 2011 day 1-2暴力60+;
*/
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
FILE *fin = fopen("hotel.in", "r");
FILE *fout = fopen("hotel.ans", "w");
const int M=200005;
struct kz
{
int color;
int cost;
};
kz s[M];
int n , k, p;
long long ans=0;
int main()
{
memset(s, -1, sizeof(s));
fscanf(fin, "%d %d %d", &n, &k, &p);
for (int i=1; i<=n; i++)
{
fscanf(fin, "%d %d", &s[i].color, &s[i].cost);
}
for (int i=1; i<=n; i++)
{
int kk=s[i].color;
int temp=s[i].cost;
for (int j=i+1; j<=n; j++){
temp=min(temp, s[j].cost);
if (kk==s[j].color && temp<=p)
{
ans++;
fprintf(fin, "%d %d\n", s[i].cost, s[j].cost);
}
}
}
fprintf(fout, "%lld\n", ans);
return 0;
}
/*
noip 2011 day 1-2剪枝100+;
*/
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
FILE *fin = fopen("hotel.in", "r");
FILE *fout = fopen("hotel.ans", "w");
const int M=200005;
struct kz
{
int color;
int cost;
int back;
};
kz s[M];
int color[M];
int yz[M];
int n , k, p;
long long ans=0;
void solve()
{
for (int i=1; i<=n; i++)
{
int kk=s[i].color;
int temp=s[i].cost;
for (int j=i+1; j<=n; j++){
temp=min(temp, s[j].cost);
if (temp<=p && s[j].color==kk){
ans+=s[j].back+1;
//printf("%d ", ans);
//printf("%d\n", s[j].back);
break;
}
}
}
}
void init()
{
memset(yz, 0, sizeof(yz));
memset(color, 0, sizeof(color));
memset(s, -1, sizeof(s));
fscanf(fin, "%d %d %d", &n, &k, &p);
for (int i=1; i<=n; i++)
{
fscanf(fin, "%d %d", &s[i].color, &s[i].cost);
color[s[i].color]++;
};
for (int i=1; i<=n; i++) s[i].back=color[s[i].color]-(++yz[s[i].color]);
/*for (int i=1; i<=n; i++) printf("%d", s[i].back);
printf("\n");*/
}
int main()
{
init();
solve();
fprintf(fout, "%lld\n", ans);
return 0;
}