Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

好感人。。。。/(ㄒoㄒ)/~~人生中第一次一遍AC/(ㄒoㄒ)/~~

Posted by CuriousCat at 2016-08-14 23:06:48 on Problem 3663
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator