Submission #8028596


Source Code Expand

Copy
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int n;
    long long ans = 0;
    vector<int> l;
    cin >> n;
    l.assign(n, 0);
    for(int i=0;i<n;i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int ok = j, ng = n;
            while(ok + 1 < ng){
                int mid = (ok + ng) / 2;
                if(l[mid] < l[i]+l[j])ok = mid;
                else ng = mid;
            }
            ans += ok-j;
        }
    }
    cout << ans << endl;
}

Submission Info

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

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