結果
| 問題 |
No.59 鉄道の旅
|
| コンテスト | |
| ユーザー |
dora_maruta
|
| 提出日時 | 2014-11-11 16:37:00 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3,521 ms / 5,000 ms |
| コード長 | 671 bytes |
| コンパイル時間 | 772 ms |
| コンパイル使用メモリ | 60,376 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 20:22:10 |
| 合計ジャッジ時間 | 8,287 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
| 外部呼び出し有り |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:15: warning: ignoring return value of ‘int system(const char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
30 | system("pause");
| ~~~~~~^~~~~~~~~
ソースコード
#include<iostream>
#include<vector>
int main(){
std::vector<int> contena;
int n, k;
std::cin >> n >> k;
int d = 0;
for (int i = 0; i < n; ++i){
int w;
std::cin >> w;
if (w > 0){
int cnt = 0;
for (auto it = contena.begin(); it != contena.end(); ++it){
if (*it >= w)cnt++;
}
if (cnt < k)contena.push_back(w);
}
else{
for (auto it = contena.begin(); it != contena.end(); ++it){
if (*it == -w){
contena.erase(it);
break;
}
}
//contena.erase(std::remove(contena.begin(), contena.end(), -w),contena.end());
}
}
std::cout << contena.size() << std::endl;
system("pause");
return 0;
}
dora_maruta