Submission #298751

# Submission time Handle Problem Language Result Execution time Memory
298751 2020-09-14T00:27:03 Z Hemimor Pairs (IOI07_pairs) C++14
30 / 100
30 ms 1664 KB
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int tp,n,d,M;
ll res=0;

int main(){
	scanf("%d%d%d%d",&tp,&n,&d,&M);
	if(tp==1){
		vi a(n);
		for(int i=0;i<n;i++) scanf("%d",&a[i]);
		sort(a.begin(),a.end());
		int I=0;
		for(int i=0;i<n;i++){
			while(a[i]-a[I]>d) I++;
			res+=i-I;
		}
	}
	if(tp==2){
		assert(0);
	}
	if(tp==3){
		assert(0);
	}
	printf("%lld\n",res);
}

Compilation message

pairs.cpp: In function 'int main()':
pairs.cpp:42:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   42 |  scanf("%d%d%d%d",&tp,&n,&d,&M);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
pairs.cpp:45:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |   for(int i=0;i<n;i++) scanf("%d",&a[i]);
      |                        ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1152 KB Output is correct
2 Correct 20 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 1536 KB Output is correct
2 Correct 27 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1536 KB Output is correct
2 Correct 30 ms 1536 KB Output is correct
3 Correct 25 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 544 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -