Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cctype>
- #include <iostream>
- #include <cstdio>
- #include <string>
- #include <cstring>
- using namespace std;
- int main(int argc, char** argv) {
- int h,l,laser,max;
- int arr[100001];
- while(scanf("%d %d",&h,&l)){
- laser=0;max=h;
- if(h==0 && l==0) break;
- for(int i=0;i<l;i++){
- scanf("%d",&arr[i]);
- }
- for(int j=l-1;j>=0;j--){
- if(max>arr[j]){
- laser+=max-arr[j];
- }
- max=arr[j];
- }
- printf("%d\n",laser);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement