結果
問題 | No.989 N×Mマス計算(K以上) |
ユーザー | MarcusAureliusAntoninus |
提出日時 | 2020-02-14 21:42:16 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 583 bytes |
コンパイル時間 | 2,620 ms |
コンパイル使用メモリ | 197,684 KB |
最終ジャッジ日時 | 2025-01-09 00:06:36 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:23: warning: format ‘%lld’ expects argument of type ‘long long int*’, but argument 4 has type ‘int64_t*’ {aka ‘long int*’} [-Wformat=] 8 | scanf("%d%d%lld %c", &N, &M, &K, &op); | ~~~^ ~~ | | | | long long int* int64_t* {aka long int*} | %ld main.cpp:11:27: warning: format ‘%lld’ expects argument of type ‘long long int*’, but argument 2 has type ‘long int*’ [-Wformat=] 11 | scanf("%lld", &e); | ~~~^ ~~ | | | | | long int* | long long int* | %ld main.cpp:13:27: warning: format ‘%lld’ expects argument of type ‘long long int*’, but argument 2 has type ‘long int*’ [-Wformat=] 13 | scanf("%lld", &e); | ~~~^ ~~ | | | | | long int* | long long int* | %ld main.cpp:33:20: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘int64_t’ {aka ‘long int’} [-Wformat=] 33 | printf("%lld\n", ans); | ~~~^ ~~~ | | | | | int64_t {aka long int} | long long int | %ld main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | scanf("%d%d%lld %c", &N, &M, &K, &op); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared wit
ソースコード
#include <bits/stdc++.h> int main() { int N, M; int64_t K; char op; scanf("%d%d%lld %c", &N, &M, &K, &op); std::vector<int64_t> A(N), B(M); for (auto& e: B) scanf("%lld", &e); for (auto& e: A) scanf("%lld", &e); std::sort(A.begin(), A.end()); std::sort(B.begin(), B.end()); B.push_back(1'000'000'000); auto calc{ [&](int64_t a, int64_t b) { if (op == '+') return a + b; else return a * b; } }; int64_t ans{}; int ok{M}; for (auto& e: A) { while (ok > 0 && calc(e, B[ok - 1]) >= K) ok--; ans += M - ok; } printf("%lld\n", ans); return 0; }