답안 #725260

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
725260 2023-04-17T05:39:57 Z Baytoro Pairs (IOI07_pairs) C++17
30 / 100
24 ms 1992 KB
#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define endl '\n'
#define ll long long
#define int long long
void fopn(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const ll INF=1e18,mod=1e9+9,N=1e5+5;
void solve(){
	int b,n,d,m;
	cin>>b>>n>>d>>m;
	if(b==1){
		vector<int> a(n);
		for(int i=0;i<n;i++) cin>>a[i];
		sort(all(a));
		int ans=0;
		for(int i=0;i<n;i++){
			int j=upper_bound(all(a),a[i]+d)-a.begin();
			ans+=j-i-1;
		}
		cout<<ans<<endl;
	}
	else{
		cout<<-1;
	}
}
main(){
	//fopn("team");
	ios;
	int T=1;
	//cin>>T;
	for(int i=1;i<=T;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

Compilation message

pairs.cpp:35:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   35 | main(){
      | ^~~~
pairs.cpp: In function 'void fopn(std::string)':
pairs.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pairs.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 1492 KB Output is correct
2 Correct 13 ms 1484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1876 KB Output is correct
2 Correct 19 ms 1872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 1868 KB Output is correct
2 Correct 19 ms 1876 KB Output is correct
3 Correct 20 ms 1992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -