답안 #756386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
756386 2023-06-11T16:29:50 Z Olympia 학교 설립 (IZhO13_school) C++17
20 / 100
2000 ms 10684 KB
#include <vector>
#include <iostream>
#include <cassert>
#include <random>
#include <cmath>
#include <map>
#include <algorithm>
#include <bitset>
#include <queue>
#include <set>
#include <stack>
using namespace std;
vector<pair<int64_t,int64_t>> music, sports;
vector<pair<int64_t,int64_t>> vec;
int64_t val () {
	int64_t ans = 0;
	for (int i = 0; i < music.size(); i++) {
		ans += music[i].first;
	}
	for (int i = 0; i < sports.size(); i++) {
		ans += sports[i].second;
	}
	return ans;
}
int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M, S;
    cin >> N >> M >> S;
    vec.resize(N);
    for (int i = 0; i < N; i++) {
    	cin >> vec[i].first >> vec[i].second;
    }
    for (auto& value: vec) {
    	if (music.size() < M or sports.size() < S) {
    		if (music.size() < M) {
    			music.push_back(value);
    		} else if (sports.size() < S) {
    			sports.push_back(value);
    		}
    	} else {
    		int64_t mx = 0;
    		for (int i = 0; i < music.size(); i++) {
    			auto m = music[i];
    			music[i] = value;
    			mx = max(mx, val());
    			music[i] = m;
    		}
    		for (int i = 0; i < sports.size(); i++) {
    			auto s = sports[i];
    			sports[i] = value;
    			mx = max(mx, val());
    			sports[i] = s;
    		}
    		//cout << "GET " << mx << endl;
    		if (mx < val()) {
    			continue;
    		}
    		for (int i = 0; i < music.size(); i++) {
    			auto m = music[i];
    			music[i] = value;
    			if (val() == mx) {
    				continue;
    			}
    			music[i] = m;
    		}
    		for (int i = 0; i < sports.size(); i++) {
    			auto s = sports[i];
    			sports[i] = value;
    			if (val() == mx) {
    				continue;
    			}
    			sports[i] = s;
    		}
    	}
    	for (int i = 0; i < music.size(); i++) {
    		for (int j = 0; j < sports.size(); j++) {
    			int64_t orig_val = val();
    			swap(music[i], sports[j]);
    			int64_t new_val = val();
    			if (new_val < orig_val) {
    				swap(music[i], sports[j]);
    			}
    		}
    	}
    }
    cout << val();
}

Compilation message

school.cpp: In function 'int64_t val()':
school.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (int i = 0; i < music.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~
school.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for (int i = 0; i < sports.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~
school.cpp: In function 'int main()':
school.cpp:35:23: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |      if (music.size() < M or sports.size() < S) {
      |          ~~~~~~~~~~~~~^~~
school.cpp:35:44: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |      if (music.size() < M or sports.size() < S) {
      |                              ~~~~~~~~~~~~~~^~~
school.cpp:36:24: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |       if (music.size() < M) {
      |           ~~~~~~~~~~~~~^~~
school.cpp:38:32: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |       } else if (sports.size() < S) {
      |                  ~~~~~~~~~~~~~~^~~
school.cpp:43:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |       for (int i = 0; i < music.size(); i++) {
      |                       ~~^~~~~~~~~~~~~~
school.cpp:49:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |       for (int i = 0; i < sports.size(); i++) {
      |                       ~~^~~~~~~~~~~~~~~
school.cpp:59:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |       for (int i = 0; i < music.size(); i++) {
      |                       ~~^~~~~~~~~~~~~~
school.cpp:67:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |       for (int i = 0; i < sports.size(); i++) {
      |                       ~~^~~~~~~~~~~~~~~
school.cpp:76:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |      for (int i = 0; i < music.size(); i++) {
      |                      ~~^~~~~~~~~~~~~~
school.cpp:77:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long int, long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |       for (int j = 0; j < sports.size(); j++) {
      |                       ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 5 ms 212 KB Output isn't correct
5 Correct 1 ms 320 KB Output is correct
6 Incorrect 62 ms 316 KB Output isn't correct
7 Execution timed out 2061 ms 328 KB Time limit exceeded
8 Execution timed out 2060 ms 596 KB Time limit exceeded
9 Execution timed out 2045 ms 468 KB Time limit exceeded
10 Execution timed out 2049 ms 468 KB Time limit exceeded
11 Execution timed out 2027 ms 468 KB Time limit exceeded
12 Execution timed out 2054 ms 448 KB Time limit exceeded
13 Execution timed out 2063 ms 1936 KB Time limit exceeded
14 Execution timed out 2072 ms 2768 KB Time limit exceeded
15 Execution timed out 2067 ms 4580 KB Time limit exceeded
16 Execution timed out 2057 ms 5756 KB Time limit exceeded
17 Execution timed out 2040 ms 8676 KB Time limit exceeded
18 Execution timed out 2062 ms 9100 KB Time limit exceeded
19 Execution timed out 2055 ms 9704 KB Time limit exceeded
20 Execution timed out 2053 ms 10684 KB Time limit exceeded