| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1364428 | activedeltorre | 3개의 봉우리 (IOI25_triples) | C++20 | 0 ms | 0 KiB |
#include "triples.h"
#include <cassert>
#include <cstdio>
#include <vector>
using namespace std;
long long count_triples(std::vector<int> H)
{
int n=H.size(),hmax=0,z;
for(int i=1; i<=n; i++)
{
hmax=max(hmax,H[i-1]);
}
int cnt=0;
for(int i=1; i<=n; i++)
{
j=i-H[i-1];
if(j>=1)
{
z=j+H[j-1];
if(z+H[z-1]==i)
{
cnt++;
}
}
}
return cnt;
}