結果
問題 | No.633 バスの運賃 |
ユーザー | GB |
提出日時 | 2018-09-17 18:47:23 |
言語 | C++17(clang) (17.0.6 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 479 bytes |
コンパイル時間 | 485 ms |
コンパイル使用メモリ | 85,696 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-08-20 10:56:00 |
合計ジャッジ時間 | 1,124 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,380 KB |
コンパイルメッセージ
main.cpp:32:2: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete] delete bus_stop; ^ [] main.cpp:11:18: note: allocated with 'new[]' here int* bus_stop = new int[n-1]; ^ main.cpp:33:2: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete] delete b; ^ [] main.cpp:13:11: note: allocated with 'new[]' here int *b = new int[n]; ^ main.cpp:34:2: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete] delete c; ^ [] main.cpp:14:11: note: allocated with 'new[]' here int *c = new int[n]; ^ 3 warnings generated.
ソースコード
#include<iostream> using namespace std; int main() { int n; cin >> n; int* bus_stop = new int[n-1]; int ans = 0; int *b = new int[n]; int *c = new int[n]; for (int i = 0;i < n - 1;i++) { cin >> bus_stop[i]; } for (int i = 0;i < n;i++) { cin >> b[i] >> c[i]; } int sumc=0, sumb=0; for (int i = 0;i < n - 1;i++) { sumc += c[i],sumb+=b[i]; ans += (sumc - sumb)*bus_stop[i]; } cout << ans << endl; delete bus_stop; delete b; delete c; return 0; }