Submission #8035011
Source Code Expand
Copy
#include <bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC optimize ("Ofast") #define F first #define S second #define MT make_tuple #define SZ(a) ((int)(a).size()) #define PB push_back #define LBS 20 #define MOD ((long long)1e9+7) //1e9+9 #define LEFT(i) (2*(i)) #define RIGHT(i) (2*(i)+1) #define PAR(i) ((i)/2) #define ALL(a) (a).begin(), (a).end() using namespace std; typedef long long ll; typedef double rat; typedef long long bi; typedef pair<int, int> ii; typedef std::vector<ii> vii; typedef std::map<int, int> mii; typedef bitset<LBS> bis; typedef std::vector<bis> vbs; template<class T> void in(T &a){ for(auto &x: a) cin >> x; } template<class T> void out(T &a, string sep=" "){ for(auto x: a) cout << x<<sep; cout << '\n'; } template<class T> void err(T &a, string sep=" "){ for(auto x: a) cerr << x <<sep; cerr << '\n'; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; std::vector<int> l(n); in(l); sort(ALL(l)); int cc=0; for(int i=0; i<n; i++) for(int j=i+1; j<n; j++){ int a=lower_bound(ALL(l),l[i]+l[j])-l.begin(); int b=upper_bound(ALL(l), abs(l[i]-l[j]))-l.begin(); cc+=a-b; if(b<=i) cc--; if(b<=j) cc--; // cerr << i << " "<<j<<" "<<cc<<"\n"; } cout << cc/3 << "\n"; }
Submission Info
Submission Time | |
---|---|
Task | D - Triangles |
User | TheLorax |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1400 Byte |
Status | WA |
Exec Time | 127 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
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 | WA | 61 ms | 256 KB |
handmade05 | AC | 1 ms | 256 KB |
random06 | AC | 126 ms | 256 KB |
random07 | AC | 126 ms | 256 KB |
random08 | AC | 124 ms | 256 KB |
random09 | AC | 127 ms | 256 KB |
random10 | AC | 125 ms | 256 KB |
random11 | AC | 127 ms | 256 KB |
random12 | AC | 125 ms | 256 KB |
random13 | AC | 127 ms | 256 KB |
random14 | AC | 127 ms | 256 KB |
sample00 | AC | 1 ms | 256 KB |
sample01 | AC | 1 ms | 256 KB |
sample02 | AC | 1 ms | 256 KB |