raghav2915's blog

By raghav2915, history, 4 years ago, In English

Diagnostics detected issues [cpp.g++17-drmemory]: Dr,2020-06-24.M Dr. Memory version 1.11.0 Dr,2020-06-24.M Running "program.exe"

This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. C:/Programs/mingw-w64-7/lib/gcc/i686-w64-mingw32/7.3.0/include/c++/debug/safe_iterator.h:283: Error: attempt to dereference a past-the-end iterator.

Objects involved in the operation: iterator "this" @ 0x105AFE48 { type = gnu_debug::_Safe_iterator<std::_Rb_tree_iterator<std::pair<int const, int> >, std::debug::map<int, int, std::less, std::allocator<std::pair<int const, int> > > > (mutable iterator); state = past-the-end; references sequence with type 'std::__debug::map<int, int, std::less, std::allocator<std::pair<int const, int> > >' @ 0x105AFE10 } Dr,2020-06-24.M Dr,2020-06-24.M NO ERRORS FOUND: Dr,2020-06-24.M 0 unique, 0 total unaddressable access(es) Dr,2020-06-24.M 0 unique, 0 total uninitialized access(es) Dr,2020-06-24.M 0 unique, 0 total invalid heap argument(s) Dr,2020-06-24.M 0 unique, 0 total GDI usage error(s) Dr,2020-06-24.M 0 unique, 0 total handle leak(s) Dr,2020-06-24.M 0 unique, 0 total warning(s) Dr,2020-06-24.M 0 unique, 0 total, 0 byte(s) of leak(s) Dr,2020-06-24.M 0 unique, 0 total, 0 byte(s) of possible leak(s) Dr,2020-06-24.M ERRORS IGNORED: Dr,2020-06-24.M 2 potential error(s) (suspected false positives) Dr,2020-06-24.M (details: K:\ramdisk\codeforces61\badf1ed7faf5982f3c9f239de8d84a43\check-4ab1a21c7557dd918d47447b5c40ad98\run\DrMemory-program.exe.4776.000\potential_errors.txt) Dr,2020-06-24.M 12 unique, 15 total, 23556 byte(s) of still-reachable allocation(s) Dr,2020-06-24.M (re-run with "-show_reachable" for details) Dr,2020-06-24.M Details: K:\ramdisk\codeforces61\badf1ed7faf5982f3c9f239de8d84a43\check-4ab1a21c7557dd918d47447b5c40ad98\run\DrMemory-program.exe.4776.000\results.txt Dr,2020-06-24.M WARNING: application exited with abnormal code 0x3

code:

include<bits/stdc++.h>

define ll long long int

using namespace std; int main(){ int t; cin>>t; while(t--){ int n,k; cin>>n>>k; int a[n],w[k]; ll sum=0; map<int,int>mp; for(int i=0; i<n; i++){ cin>>a[i]; sum+=a[i]; mp[a[i]]++; } for(int i=0; i<k; i++){ cin>>w[i]; } if(n==k){ cout<<2*sum<<endl; continue; } ll res=0; sort(a,a+n); sort(w,w+k); map<int,int>::iterator max = mp.end(); map<int,int>::iterator min = mp.begin(); for(int i=0; i<k; i++){ if(max->second==0)max--; if(min->second==0)min++; if(w[i]==1 && max->second>0){ res+=(2*(max->first)); max->second--; }else{ res+=(max->first + min->first); max->second--; min->second--; } } cout<<res<<"\n"; } }

Full text and comments »

  • Vote: I like it
  • -22
  • Vote: I do not like it