Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
stl 大牛们看一下咯!这这题用multiset, 帮帮忙看哪儿出问题了 为什么WA??谢谢呀#include <iostream> #include <set> using namespace std; const int N=1000010; int f[N]; int ans[N][2]; int main() { //freopen("c.in","r",stdin); int n, k; scanf("%d%d", &n, &k); int i; for (i=1; i<=n; i++) scanf("%d", &f[i]); multiset <int> MS; for (i=1; i<=k; i++) MS.insert(f[i]); ans[k][0] = * MS.begin(); ans[k][1] = * MS.rbegin(); for (i=k+1; i<=n; i++) { MS.insert(f[i]); MS.erase(f[i-k]); ans[i][0] = * MS.begin(); ans[i][1] = * MS.rbegin(); } printf("%d", ans[k][0]); for (i=k+1; i<=n; i++) printf(" %d", ans[i][0]); printf("\n%d", ans[k][1]); for (i=k+1; i<=n; i++) printf(" %d", ans[i][1]); printf("\n"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator