結果
| 問題 |
No.59 鉄道の旅
|
| コンテスト | |
| ユーザー |
dora_maruta
|
| 提出日時 | 2014-11-11 16:49:03 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 717 bytes |
| コンパイル時間 | 547 ms |
| コンパイル使用メモリ | 59,772 KB |
| 実行使用メモリ | 13,860 KB |
| 最終ジャッジ日時 | 2024-12-24 20:23:14 |
| 合計ジャッジ時間 | 15,666 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 2 WA * 9 TLE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:34:15: warning: ignoring return value of ‘int system(const char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
34 | system("pause");
| ~~~~~~^~~~~~~~~
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
int contena[1000001];
int main(){
//std::vector<int> contena;
int n, k;
std::cin >> n >> k;
int m = 0;
int d = 0;
for (int i = 0; i < n; ++i){
int w;
std::cin >> w;
m = std::max(m, w);
if (w > 0){
int cnt = 0;
for (int j = m; j >w; --j){
if (contena[j] != 0)cnt+=contena[j];
}
if (cnt < k)contena[w]++;
}
else{
if (contena[-w] != 0)contena[-w]--;
//contena.erase(std::remove(contena.begin(), contena.end(), -w),contena.end());
}
}
int ans = 0;
for (int i = 1; i < m; ++i){
if (contena[i] != 0)ans += contena[i];
}
std::cout << ans << std::endl;
system("pause");
return 0;
}
dora_maruta