Submission #7034041


Source Code Expand

Copy
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     @hamayanhamayan
    /   \     | |
    /   / ̄ ̄ ̄ ̄/  |
  __(__ニつ/     _/ .| .|____
     \/____/ (u ⊃
---------------------------------------------------------------------------------------------------*/














int N, P, Q, A[101010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> P >> Q;
    rep(i, 0, N) cin >> A[i];

    if((P + Q) % 2 != 0) {
        cout << 0 << endl;
        return;
    }

    int R = P - (P + Q) / 2;

    ll ans = 0;
    ll lft = 0;
    map<int,ll> cnt;
    rep(i, 0, N) cnt[A[i]]++;

    rep(y, 0, N) {
        cnt[A[y]]--;

        ans += lft * cnt[R - A[y]];

        if(A[y] == (P + Q) / 2) lft++;
    }

    cout << ans << endl;
}





Submission Info

Submission Time
Task D - 新入生歓迎数列 2
User hamayanhamayan
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1785 Byte
Status AC
Exec Time 64 ms
Memory 7808 KB

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 31
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
test_01.txt AC 1 ms 256 KB
test_02.txt AC 7 ms 512 KB
test_03.txt AC 6 ms 384 KB
test_04.txt AC 64 ms 7808 KB
test_05.txt AC 11 ms 640 KB
test_06.txt AC 12 ms 640 KB
test_07.txt AC 12 ms 640 KB
test_08.txt AC 12 ms 640 KB
test_09.txt AC 12 ms 640 KB
test_10.txt AC 12 ms 640 KB
test_11.txt AC 12 ms 640 KB
test_12.txt AC 12 ms 640 KB
test_13.txt AC 12 ms 640 KB
test_14.txt AC 12 ms 640 KB
test_15.txt AC 12 ms 640 KB
test_16.txt AC 2 ms 384 KB
test_17.txt AC 4 ms 512 KB
test_18.txt AC 14 ms 1024 KB
test_19.txt AC 30 ms 2048 KB
test_20.txt AC 3 ms 512 KB
test_21.txt AC 6 ms 640 KB
test_22.txt AC 28 ms 2176 KB
test_23.txt AC 37 ms 2944 KB
test_24.txt AC 35 ms 2560 KB
test_25.txt AC 10 ms 896 KB
test_26.txt AC 13 ms 640 KB
test_27.txt AC 13 ms 640 KB
test_28.txt AC 1 ms 256 KB