0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ABC071 C - Make a Rectangle

Posted at

最初cnt[a[i]]で表示して、大きい方から見て行って、2以上countされている箇所をピックアップすればいいと思ったけど、vectorの要素数が10^9に対応できていなくて、詰まってしまった。

ABC071C.cpp
# include <bits/stdc++.h>
using namespace std;

int main() {
 int n,acnt=0,bcnt=0;
 cin >> n;
  vector<long long> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  long long b=0,c=0;

  sort(a.begin(),a.end(),greater<long long>());
    for(int i=0;i<n;i++){
      if(a[i]==a[i+1]){
        if(b==0)b=a[i];
        else if(c==0)c=a[i];
        i++;
      }
    }
    cout <<  (long long)b*c << endl;
  }

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?