Submission #464417

# Submission time Handle Problem Language Result Execution time Memory
464417 2021-08-13T07:26:36 Z prvocislo Sticks (POI11_pat) C++17
100 / 100
236 ms 18044 KB
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int k;
	cin >> k;
	vector<pair<int, int> > v;
	for (int i = 1; i <= k; i++)
	{
		int n; cin >> n;
		for (int j = 0, len; j < n; j++)
		{
			cin >> len;
			v.push_back({ len, i });
		}
	}
	sort(v.begin(), v.end());
	vector<int> maxi(k+1, -1e9);
	for (int i = 0; i < v.size(); i++)
	{
		int i1 = 0, i2 = 0;
		for (int j = 1; j <= k; j++) if (j != v[i].second)
		{
			if (maxi[j] > maxi[i1]) i2 = i1, i1 = j;
			else if (maxi[j] > maxi[i2]) i2 = j;
		}
		if (maxi[i1] + maxi[i2] > v[i].first)
		{
			cout << i1 << " " << maxi[i1] << " " << i2 << " " << maxi[i2] << " " << v[i].second << " " << v[i].first << "\n";
			return 0;
		}
		maxi[v[i].second] = v[i].first;
	}
	cout << "NIE\n";
	return 0;
}

Compilation message

pat.cpp: In function 'int main()':
pat.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for (int i = 0; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Oczekiwano NIE
2 Correct 7 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Oczekiwano NIE
2 Correct 9 ms 1232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Oczekiwano NIE
2 Correct 27 ms 2176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 848 KB Oczekiwano NIE
2 Correct 34 ms 3784 KB Output is correct
3 Correct 24 ms 2124 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1996 KB Oczekiwano NIE
2 Correct 70 ms 6732 KB Output is correct
3 Correct 37 ms 3656 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 119 ms 9080 KB Output is correct
2 Correct 72 ms 6924 KB Output is correct
3 Correct 57 ms 4112 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 114 ms 9100 KB Output is correct
2 Correct 79 ms 6864 KB Output is correct
3 Correct 87 ms 6840 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 233 ms 17828 KB Output is correct
2 Correct 91 ms 7192 KB Output is correct
3 Correct 105 ms 7348 KB Oczekiwano NIE
# Verdict Execution time Memory Grader output
1 Correct 236 ms 18044 KB Output is correct
2 Correct 106 ms 8312 KB Output is correct
3 Correct 129 ms 12884 KB Oczekiwano NIE