Submission #659819

# Submission time Handle Problem Language Result Execution time Memory
659819 2022-11-19T10:29:39 Z Gabi88 Poi (IOI09_poi) C++14
100 / 100
514 ms 31872 KB
#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define F first
#define S second

vector<pair<LL, pair<LL, int> > > v;
unsigned LL n, m, k, l[2009][2009], rj[2009], na[2009], sum, usp, pos;

int cmt(pair<LL, pair<LL, int> > a, pair<LL, pair<LL, int> > b){
	if (a.F != b.F) return a.F > b.F;
	if (a.S.F != b.S.F) return a.S.F > b.S.F;
	return a.S.S < b.S.S;
}

int main(){
	cin >> n >> m >> k;
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> l[i][j];
			na[i] += l[i][j];
			rj[j] += (l[i][j] == 0);
		}
	}
	for(int i=0; i<n; i++){
		sum = 0;
		for(int j=0; j<m; j++) sum += rj[j]*l[i][j];
		if (k == i+1) cout << sum << " ";
		v.push_back(make_pair(sum, make_pair(na[i], i+1)));
	}
	sort(v.begin(), v.end(), cmt);
	for(int i=0; i < n; i++){
		if (v[i].S.S == k) cout << i+1;/*
		if (sum != v[i].F or usp != v[i].S.F or i == 0){
			sum = v[i].F;
			usp = v[i].S.F;
			pos = i+1;
		}
		if (v[i].S.S == k){cout << sum << " " << pos; return 0;}*/
	}
	return 0;
}

Compilation message

poi.cpp: In function 'int main()':
poi.cpp:19:16: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   19 |  for(int i=0; i<n; i++){
      |               ~^~
poi.cpp:20:17: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   20 |   for(int j=0; j<m; j++){
      |                ~^~
poi.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   26 |  for(int i=0; i<n; i++){
      |               ~^~
poi.cpp:28:17: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   28 |   for(int j=0; j<m; j++) sum += rj[j]*l[i][j];
      |                ~^~
poi.cpp:29:9: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   29 |   if (k == i+1) cout << sum << " ";
      |       ~~^~~~~~
poi.cpp:33:17: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   33 |  for(int i=0; i < n; i++){
      |               ~~^~~
poi.cpp:34:16: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   34 |   if (v[i].S.S == k) cout << i+1;/*
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 608 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 5 ms 1236 KB Output is correct
11 Correct 17 ms 2380 KB Output is correct
12 Correct 28 ms 3796 KB Output is correct
13 Correct 101 ms 7736 KB Output is correct
14 Correct 119 ms 10956 KB Output is correct
15 Correct 201 ms 16900 KB Output is correct
16 Correct 214 ms 18252 KB Output is correct
17 Correct 326 ms 23952 KB Output is correct
18 Correct 355 ms 27136 KB Output is correct
19 Correct 474 ms 31872 KB Output is correct
20 Correct 514 ms 31840 KB Output is correct