Submission #761556

#TimeUsernameProblemLanguageResultExecution timeMemory
761556KN200711Skyline (IZhO11_skyline)C++14
0 / 100
1 ms296 KiB
# include <bits/stdc++.h> # define ll long long # define fi first # define se second using namespace std; int main() { int N; scanf("%d", &N); vector<int> arr(N); for(int i=0;i<N;i++) scanf("%d", &arr[i]); bool ls = 1; int ans = 0; while(ls) { ls = 0; for(int c=0;c<N;c++) { if(arr[c] == 0) continue; ls = 1; int mn = 1e9, cnt = 0; for(int d=c;d<N;d++) { if(arr[d] == 0) break; cnt++; mn = min(mn, arr[d]); } for(int d=c;d<N;d++) { if(arr[d] == 0) break; arr[d] -= mn; } ans += (2 * cnt + 1) * mn; break; } } printf("%d\n", ans); return 0; }

Compilation message (stderr)

skyline.cpp: In function 'int main()':
skyline.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d", &N);
      |  ~~~~~^~~~~~~~~~
skyline.cpp:11:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  for(int i=0;i<N;i++) scanf("%d", &arr[i]);
      |                       ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...