結果
問題 |
No.633 バスの運賃
|
ユーザー |
|
提出日時 | 2018-09-17 18:47:23 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 479 bytes |
コンパイル時間 | 641 ms |
コンパイル使用メモリ | 119,552 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-30 12:41:19 |
合計ジャッジ時間 | 1,093 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 |
コンパイルメッセージ
main.cpp:32:2: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete] 32 | delete bus_stop; | ^ | [] main.cpp:11:18: note: allocated with 'new[]' here 11 | 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] 33 | delete b; | ^ | [] main.cpp:13:11: note: allocated with 'new[]' here 13 | 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] 34 | delete c; | ^ | [] main.cpp:14:11: note: allocated with 'new[]' here 14 | 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; }