fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int MaxN=3e4;
  5.  
  6. int N;
  7. int s[MaxN];
  8. int e[MaxN];
  9. int main (){
  10. for(int t=1;cin>>N;t++){
  11. for(int n=0;n<N;n++)
  12. cin>>s[n]>>e[n];
  13. sort(s,s+N);
  14. sort(e,e+N);
  15. int ans=N*(N-1)/2;
  16. for(int m=0,n=0;n<N;n++){
  17. while(m<N && e[m]<=s[n])
  18. m++;
  19. ans-=m;
  20. }
  21. cout<<"Case "<<t<<": "<<ans<<"\n";
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
Standard output is empty