Submission #8030081


Source Code Expand

Copy
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 2005
using namespace std;

typedef long long ll;
ll n, s, t, a[N];
ll f(ll p) {return p > 0 ? p : 0;}
int main()
{
	ll i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
	}
	sort(a, a + n);
	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			t = upper_bound(a, a + n, a[i] + a[j] - 1) - a;
			s += f(t - j - 1);
		}
	}
	cout << s;
    return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%lld", &a[i]);
                        ^

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 44 ms 256 KB
handmade05 AC 1 ms 256 KB
random06 AC 60 ms 256 KB
random07 AC 61 ms 256 KB
random08 AC 60 ms 256 KB
random09 AC 60 ms 256 KB
random10 AC 60 ms 256 KB
random11 AC 61 ms 256 KB
random12 AC 60 ms 256 KB
random13 AC 60 ms 256 KB
random14 AC 61 ms 256 KB
sample00 AC 1 ms 256 KB
sample01 AC 1 ms 256 KB
sample02 AC 1 ms 256 KB