1 solutions

  • 0
    @ 2025-11-5 15:30:28

    C++ :

    #include<iostream>
    #include<algorithm>
    using namespace std;
    
    const int N = 51;
    int available[N], number[N];
    
    int main()
    {
    	int n, k, p;
    	int i, color, money;
    	long long ans = 0;
    	
    	cin >> n >> k >> p;
    	for (i = 1; i <= n; i++)
    	{
    		cin >> color >> money;
    		if (money <= p) copy(number, number + N, available);
    		ans += available[color];
    		if (money <= p) available[color]++;
    		number[color]++;
    	}
    	
    	cout << ans << endl;
    	
    	return 0;
    }
    
    

    Pascal :

    var  
      a,b:array[0..50] of longint;  
      i,j,k,m,n,s,t:longint;  
    begin  
      readln(n,k,m);  
      j:=0;
    	fillchar(a,sizeof(a),0);
      for i:=1 to n do  
      begin  
        readln(s,t);  
        a[s]:=a[s]+1;  
        if t<=m then  
        begin  
          b:=a;  
          j:=j+b[s]-1;  
        end else j:=j+b[s];  
      end;  
      write(j);  
    end.
    
    • 1

    Information

    ID
    16867
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By