結果
| 問題 |
No.723 2つの数の和
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-29 09:41:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 690 bytes |
| コンパイル時間 | 359 ms |
| コンパイル使用メモリ | 44,492 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-12 08:09:26 |
| 合計ジャッジ時間 | 3,921 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 7 WA * 14 RE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d%lld", &array_len, &x);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d", &temp);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <algorithm>
#include <vector>
typedef long long int ll;
int main(void) {
int array_len;
ll x;
scanf("%d%lld", &array_len, &x);
std::vector<int> a;
for (int i = 0; i < array_len; ++i) {
int temp = 0;
scanf("%d", &temp);
a.push_back(temp);
}
std::sort(a.begin(), a.end());
int count = 0;
for (int i = 0; i < array_len; i++) {
int tgt = x - a[i];
if (std::binary_search(a.begin(), a.end(), tgt)) {
int j = 1;
count++;
while (a[i + j] == tgt) {
j++;
count++;
}
}
}
printf("%d\n", count);
}