Submission #337584

# Submission time Handle Problem Language Result Execution time Memory
337584 2020-12-21T07:06:29 Z kutbilim_one UFO (IZhO14_ufo) C++14
30 / 100
2000 ms 23788 KB
/** kutbilim.one **/
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(),x.end()
#define int long long
#define endl '\n'
                               /*
ifstream in("test.txt"); 
#define cin in                   */

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m, r, k, p;
    cin >> n >> m >> r >> k >> p;
    
    vector< vector<int> > a(n+1, vector<int>(m+1));
    for(int i = 1; i <= n; i++)
	for(int j = 1; j <= m; j++) cin >> a[i][j];

	while(k--){
		char side;
		int pos, h;
		cin >> side >> pos >> h;

		int shots = r;
		if(side == 'W'){
			for(int j = 1; j <= m && shots > 0; j++)
				if(a[pos][j] >= h) a[pos][j]--, shots--;
		}else if(side == 'E'){
		    for(int j = m; j >= 1 && shots > 0; j--)
				if(a[pos][j] >= h) a[pos][j]--, shots--;
		}else if(side == 'N'){
		    for(int i = 1; i <= n && shots > 0; i++)
				if(a[i][pos] >= h) a[i][pos]--, shots--;
		}else{
		    for(int i = n; i >= 1 && shots > 0; i--)
				if(a[i][pos] >= h) a[i][pos]--, shots--;
		}
	}

	vector< vector<int> > sums(n+2, vector<int>(m+1));
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
        	sums[i][j] += a[i][j] + sums[i][j-1];
        }
	}
	for(int i = 1; i <= m; i++){
		for(int j = 1; j <= n; j++){
        	sums[j][i] += sums[j-1][i];
        }
	}
	                  
	int maxx = 0;
	for(int i = p; i <= n; i++){
		for(int j = p; j <= m; j++){
			maxx = max(maxx, sums[i][j]-sums[i][j-p]-sums[i-p][j]+sums[i-p][j-p]);	
		} 
	}
	    
    cout << maxx;

    return 0;
}

Compilation message

ufo.cpp: In function 'int main()':
ufo.cpp:21:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   21 |     for(int i = 1; i <= n; i++)
      |     ^~~
ufo.cpp:24:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   24 |  while(k--){
      |  ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 5 ms 620 KB Output is correct
5 Correct 18 ms 2028 KB Output is correct
6 Correct 78 ms 11372 KB Output is correct
7 Execution timed out 2074 ms 14836 KB Time limit exceeded
8 Execution timed out 2098 ms 11484 KB Time limit exceeded
9 Execution timed out 2098 ms 11364 KB Time limit exceeded
10 Execution timed out 2044 ms 11868 KB Time limit exceeded
11 Execution timed out 2084 ms 11328 KB Time limit exceeded
12 Execution timed out 2040 ms 11868 KB Time limit exceeded
13 Execution timed out 2015 ms 15320 KB Time limit exceeded
14 Execution timed out 2099 ms 11968 KB Time limit exceeded
15 Execution timed out 2083 ms 12636 KB Time limit exceeded
16 Execution timed out 2079 ms 11200 KB Time limit exceeded
17 Execution timed out 2075 ms 18028 KB Time limit exceeded
18 Execution timed out 2079 ms 14572 KB Time limit exceeded
19 Execution timed out 2081 ms 12084 KB Time limit exceeded
20 Execution timed out 2082 ms 23788 KB Time limit exceeded