fork download
  1. class Solution {
  2. public:
  3. long long minimumPossibleSum(int n, int target)
  4. {
  5. long long sum=0;
  6. unordered_map<int,int>m;
  7. int cnt=0;
  8. int i=1;
  9. while(cnt<n)
  10. {
  11.  
  12. if(m.find(i) == m.end())
  13. {
  14. sum+=i;
  15. cnt++;
  16. }
  17. m[target-i]++;
  18. i++;
  19. }
  20. return sum;
  21. }
  22. };
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘long long int Solution::minimumPossibleSum(int, int)’:
prog.cpp:6:9: error: ‘unordered_map’ was not declared in this scope
         unordered_map<int,int>m;
         ^~~~~~~~~~~~~
prog.cpp:6:23: error: expected primary-expression before ‘int’
         unordered_map<int,int>m;
                       ^~~
prog.cpp:12:16: error: ‘m’ was not declared in this scope
             if(m.find(i) == m.end())
                ^
prog.cpp:17:13: error: ‘m’ was not declared in this scope
             m[target-i]++;
             ^
stdout
Standard output is empty