0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

競プロ日記#25/07/23

0
Posted at

AtCoder

AtCoder Beginner Contest 344

C - A+B+C

  • 250点のC問題で比較的簡単だった。
  • 累積和っぽくA+B+Cをあらかじめ求めてSetに突っ込んでいき、最後にfind()で捜査していけば一発でACできる
int main() {
    long long N,M,L;
    cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    cin >> M;
    vector<long long> B(M);
    for (int i = 0; i < M; i++) cin >> B[i];
    cin >> L;
    vector<long long> C(L);
    for (int i = 0; i < L; i++) cin >> C[i];
    set <long long> sums;
    for (int i = 0; i < N; i++){
        for (int j = 0; j < M; j++) {
            for (int k = 0; k < L; k++) {
                sums.insert(A[i] + B[j] + C[k]);
            }
        }
    }
    long long Q;
    cin >> Q;
    for (int i = 0; i < Q; i++) {
        long long x;
        cin >> x;
        if (sums.find(x) != sums.end()) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;   
        }
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?