#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
namespace Subtask1{
vector<int> v;
int getsum(int x, int y, int m){
int result = 0;
if(y <= m)
result += v[y];
else
result += v[m];
if(0 < x)
result -= v[x - 1];
return result;
}
void solve(){
int n, d, m;
cin >> n >> d >> m;
v.resize(1 + m);
for(int i = 1;i <= n; i++){
int x;
cin >> x;
v[x]++;
}
for(int i = 1;i <= m; i++)
v[i] += v[i - 1];
ll result = 0;
for(int i = 1;i <= m; i++)
if(0 < v[i] - v[i - 1])
result += (v[i] - v[i - 1]) * getsum(i - d, i + d, m);
result -= n;
cout << result / 2 << '\n';
}
}
namespace Subtask2{
void solve(){
return ;
}
}
namespace Subtask3{
void solve(){
return ;
}
}
int main()
{
int type;
cin >> type;
if(type == 1)
Subtask1::solve();
else if(type == 2)
Subtask2::solve();
else if(type == 3)
Subtask3::solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
517 ms |
293908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
760 KB |
Output is correct |
2 |
Correct |
38 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
587 ms |
275184 KB |
Output is correct |
2 |
Correct |
566 ms |
275192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
575 ms |
275196 KB |
Output is correct |
2 |
Correct |
550 ms |
275280 KB |
Output is correct |
3 |
Correct |
549 ms |
275192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |