Submission #149131

# Submission time Handle Problem Language Result Execution time Memory
149131 2019-09-01T05:47:29 Z 샌즈뼈(#3582, exqt, esselem) Crosses on the Grid (FXCUP4_cross) C++17
63 / 100
140 ms 6500 KB
#include "cross.h"
#include <bits/stdc++.h>
using namespace std;

long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
	int N = I.size();

  vector<pair<int, int>> v;
  for(int i=0; i<N; i++) v.emplace_back(I[i], O[i]);

  sort(v.rbegin(), v.rend());

  //for(int i=0;i <N; i++) cout << v[i].first << ' '; cout << endl;
  //for(int i=0;i <N; i++) cout << v[i].second << ' '; cout << endl;


  set<int> s;
  for(int i=0; i<K-1; i++) {
    s.insert(v[i].second);
  }

  long long res = 0;
  for(int i=K-1; i<N; i++) {
    if(s.size()+1 > K) s.erase(s.begin());
    s.insert(v[i].second);

    int ii = v[i].first;
    int oo = *(s.begin());

    //cout <<r << ' ' << t << endl;

    res = max(res, 1LL*oo*oo - 1LL*(oo-ii)*(oo-ii));
  }

	return res;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:24:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(s.size()+1 > K) s.erase(s.begin());
        ~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 128 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 12 ms 640 KB Output is correct
6 Correct 113 ms 5736 KB Output is correct
7 Correct 114 ms 5736 KB Output is correct
8 Correct 113 ms 5740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 128 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 12 ms 640 KB Output is correct
6 Correct 113 ms 5736 KB Output is correct
7 Correct 114 ms 5736 KB Output is correct
8 Correct 113 ms 5740 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 12 ms 768 KB Output is correct
13 Correct 65 ms 3184 KB Output is correct
14 Correct 116 ms 5740 KB Output is correct
15 Correct 117 ms 5736 KB Output is correct
16 Correct 121 ms 5740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 128 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 12 ms 640 KB Output is correct
6 Correct 113 ms 5736 KB Output is correct
7 Correct 114 ms 5736 KB Output is correct
8 Correct 113 ms 5740 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 6 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 12 ms 768 KB Output is correct
13 Correct 65 ms 3184 KB Output is correct
14 Correct 116 ms 5740 KB Output is correct
15 Correct 117 ms 5736 KB Output is correct
16 Correct 121 ms 5740 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 15 ms 1152 KB Output is correct
20 Correct 67 ms 3308 KB Output is correct
21 Correct 92 ms 5096 KB Output is correct
22 Correct 116 ms 5736 KB Output is correct
23 Correct 117 ms 5736 KB Output is correct
24 Incorrect 140 ms 6500 KB Output isn't correct
25 Halted 0 ms 0 KB -