@LevMckinney/

Nailed It!

C++

No description

fork
loading
Files
  • main.cpp
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <vector>

int main() 
{
  int n = 0;
  
  std::cin >> n;
  
  std::vector<int> data(n,0);
  
  for(int i = 0; i < n; ++i)
  {
    std::cin >> data[i];
  }
  
  std::cout << "lastInstanceCheck";
  
  std::vector<int> lastInstance(n, 0);

  for(int i = 0; i < n; ++i)
  {
    for(int j = i; j >= 0; --j)
    {
      if(data[i] == data[j])
      {
        lastInstance[i] = j;
      }
    }
  }
  
  std::cout << "lastInstanceCheck";
  
  std::vector<int> plankLength((n*n)/2 - n/2 + 1, 0);
  
  for(int i = 0; i < n; ++i)
  {
    for(int j = i + 1; j < n; ++j)
    {
      if(lastInstance[j] == 0 && lastInstance[i] <= i+1)
      {
        plankLength[i] = data[i] + data[j];
        std::cout << plankLength[i] ;
      }
    }
  }
  
  return 0;
}