Submission #676469

#TimeUsernameProblemLanguageResultExecution timeMemory
676469penguin133Orchard (NOI14_orchard)C++17
25 / 25
191 ms10060 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int r,c; cin >> r >> c; int g[r][c]; long long a=0,b=0; string s; for(int i=0;i<r;i++){ for(int j=0;j<c;j++){ cin >> g[i][j]; if(g[i][j] == 1){ b++; } else{ g[i][j] = -1; } } } long long cnt= 0; long long maxi = 0; int d = -1; int e = -1; int d1=-1, e1 = -1; long long mini = 1e18 + 5; for(int i=0;i<r;i++){ int cnt2[c]; for(int x=0;x<c;x++){ cnt2[x] = g[i][x]; } for(int j=i;j<r;j++){ if(j != i){ for(int x=0;x<c;x++){ cnt2[x] += g[j][x]; } } cnt = 0; for(int k=0;k<c;k++){ cnt += cnt2[k]; if(cnt > maxi){ maxi = cnt; } if(cnt < 0){ cnt = 0; } } } } cout << b - maxi; }

Compilation message (stderr)

orchard.cpp: In function 'int main()':
orchard.cpp:8:12: warning: unused variable 'a' [-Wunused-variable]
    8 |  long long a=0,b=0;
      |            ^
orchard.cpp:23:6: warning: unused variable 'd' [-Wunused-variable]
   23 |  int d = -1;
      |      ^
orchard.cpp:24:6: warning: unused variable 'e' [-Wunused-variable]
   24 |  int e = -1;
      |      ^
orchard.cpp:25:6: warning: unused variable 'd1' [-Wunused-variable]
   25 |  int d1=-1, e1 = -1;
      |      ^~
orchard.cpp:25:13: warning: unused variable 'e1' [-Wunused-variable]
   25 |  int d1=-1, e1 = -1;
      |             ^~
orchard.cpp:26:12: warning: unused variable 'mini' [-Wunused-variable]
   26 |  long long mini = 1e18 + 5;
      |            ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...