結果
問題 |
No.59 鉄道の旅
|
ユーザー |
![]() |
提出日時 | 2014-11-07 00:29:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 778 bytes |
コンパイル時間 | 852 ms |
コンパイル使用メモリ | 71,728 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-12-24 20:12:09 |
合計ジャッジ時間 | 20,642 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 9 TLE * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | int n,k;scanf("%d%d",&n,&k); | ~~~~~^~~~~~~~~~~~~~ main.cpp:21:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%d",&a); | ~~~~~^~~~~~~~~
ソースコード
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <vector> #include <string> #include <algorithm> #include <map> using namespace std; //namaega184 int main(){ int n,k;scanf("%d%d",&n,&k); // int w[1000001]={}; int a; map<int,int> mp; long long ans=0; long long over=0; long long total=0; for(int i=0;i<n;i++){ scanf("%d",&a); if(a<0){ a=-a; if(mp[a]>0){ mp[a]--; total-=a; } } else{ int num=0; for(auto it=mp.begin();it!=mp.end();it++){ if(it->first<a)continue; num+=it->second; if(num>=k)break; } if(num>=k)continue; mp[a]++; total+=a; } } for(auto it=mp.begin();it!=mp.end();it++){ ans+=it->second; } printf("%lld\n",ans); return 0; }