Submission #8028922


Source Code Expand

Copy
#include <bits/stdc++.h>

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int> L(N);
	for (auto& e: L) scanf("%d", &e);
	std::sort(L.begin(), L.end());
	int ans{};
	for (int i{2}; i < N; i++)
		for (int j{1}; j < i; j++)
		{
			int upper{(int)(std::upper_bound(L.begin(), L.end(), L[i] - L[j]) - L.begin())};
			ans += std::max(0, j - upper);
		}
	printf("%d\n", ans);

	return 0;
}

Submission Info

Submission Time
Task D - Triangles
User TanakaTaroh
Language C++14 (GCC 5.4.1)
Score 400
Code Size 405 Byte
Status AC
Exec Time 69 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:6:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
                 ^
./Main.cpp:8:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  for (auto& e: L) scanf("%d", &e);
                                  ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 15
Set Name Test Cases
Sample sample00, sample01, sample02
All handmade03, handmade04, handmade05, random06, random07, random08, random09, random10, random11, random12, random13, random14, sample00, sample01, sample02
Case Name Status Exec Time Memory
handmade03 AC 1 ms 256 KB
handmade04 AC 21 ms 256 KB
handmade05 AC 1 ms 256 KB
random06 AC 68 ms 256 KB
random07 AC 68 ms 256 KB
random08 AC 68 ms 256 KB
random09 AC 67 ms 256 KB
random10 AC 67 ms 256 KB
random11 AC 68 ms 256 KB
random12 AC 68 ms 256 KB
random13 AC 69 ms 256 KB
random14 AC 69 ms 256 KB
sample00 AC 1 ms 256 KB
sample01 AC 1 ms 256 KB
sample02 AC 1 ms 256 KB