#include <iostream> #include <string> #include <map> #include <set> #include <map> using namespace std; int main(){ int n; cin >> n; int wood_lens[2001] = {0}; int fences_lens[4001] = {0}; //set<int> woods; for (int x=0; x<n; x++){ int num; cin >> num; wood_lens[num]++; // woods.insert(num); } int greatest_number_of_appearences = 0; int answer = 0; //4 //1 2 3 4 // for(int i = 0; i < 2000; i++){ for(int j = i; j < 2001; j++){ if(wood_lens[i]!= 0 && wood_lens[j] != 0){ if(i == j){ fences_lens[i+j] += wood_lens[j]/2; } else{ fences_lens[i+j] += min(wood_lens[i], wood_lens[j]); } } } } for(int i = 0; i < 4001; i++){ if(greatest_number_of_appearences < fences_lens[i]){ greatest_number_of_appearences = fences_lens[i]; answer = 1; } else if (greatest_number_of_appearences == fences_lens[i]){ answer++; } } /*for(int i = 0; i < 4001; i++){ if(greatest_number_of_appearences == fences_lens[i]){ answer++; } }*/ /*int greatest_sum_numofboards; map<int,int> sum_to_sumcount_map; for (int x=0; x<n; x++){ for (int y=x+1; y<n; y++){ int sum = wood_lens[x] + wood_lens[y]; if (sum_to_sumcount_map.find(sum) == sum_to_sumcount_map.end()){ sum_to_sumcount_map[sum] = 1; } else{ sum_to_sumcount_map[sum]++; } if (sum_to_sumcount_map[sum] > greatest_number_of_appearences){ greatest_number_of_appearences = sum_to_sumcount_map[sum]; answer = 1; } else if (sum_to_sumcount_map[sum] == greatest_number_of_appearences){ answer++; } } }*/ cout << greatest_number_of_appearences << " " << answer; }
top of page
Recent Posts
See All#include<iostream> #include <vector> #include <algorithm> #include <cmath> #include <stack> using namespace std; int main() { int r, c,...
s1 = input() s2 = input() silly = '' silly_o = '' quiete = '-' i = 0 j = 0 while i < len(s1) and j < len(s2): if s1[i] != s2[j]: if...
#include<iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; bool rowcom(pair<int, int> a, pair<int,...
bottom of page
コメント