Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
好感人。。。。/(ㄒoㄒ)/~~人生中第一次一遍AC/(ㄒoㄒ)/~~#include <algorithm> #include <iostream> #include <vector> using namespace std; int main(int argc, char *argv[]) { int n, s;cin >> n >> s; vector<int> cows(n); for (int i = 0;i < n;++i) cin >> cows[i]; sort(cows.begin(), cows.end()); int ans = 0; for (int i = 0;i < n;++i) { ans += upper_bound(cows.begin(), cows.end(), s - cows[i]) - cows.begin(); if (cows[i] <= (s - cows[i]) ) --ans; } cout << ans / 2 << endl; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator