답안 #9078

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
9078 2014-09-27T11:24:03 Z levant916 Penalty calculation (kriii2_PE) C++
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

typedef pair<int, int> PAIR;

bool cmp(PAIR& a, PAIR& b) {
	return a.second > b.second;
}
int index[301];
int main(void) {

	int T;
	vector<PAIR> set;
	cin >> T;
	for (int i = 0; i < T; i++) {
		int t, s;
		cin >> t >> s;
		index[t] = i + 1;
		set.push_back(PAIR(t, s));
	}
	sort(set.begin(), set.end(), cmp);

	int tf = set[0].first;
	int sf = set[0].second;
	int p ;

	if (sf == 0) {
		p = 0;
	}
	else if (sf == 1 || sf == 4) {
		p = tf + (index[tf] - 1) * 20;
	}
	cout << p << endl;

	return 0;
}

Compilation message

PE.cpp:14:14: error: 'int index [301]' redeclared as different kind of symbol
/usr/include/string.h:482:1: error: previous declaration of 'const char* index(const char*, int)'
PE.cpp: In function 'int main()':
PE.cpp:23:10: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
PE.cpp:36:21: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
In file included from /usr/include/c++/4.6/algorithm:63:0,
                 from PE.cpp:4:
/usr/include/c++/4.6/bits/stl_algo.h: In function '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >, _Tp = std::pair<int, int>, _Compare = bool (*)(std::pair<int, int>&, std::pair<int, int>&)]':
/usr/include/c++/4.6/bits/stl_algo.h:2265:78:   instantiated from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >, _Compare = bool (*)(std::pair<int, int>&, std::pair<int, int>&)]'
/usr/include/c++/4.6/bits/stl_algo.h:2306:62:   instantiated from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >, _Size = long int, _Compare = bool (*)(std::pair<int, int>&, std::pair<int, int>&)]'
/usr/include/c++/4.6/bits/stl_algo.h:5445:4:   instantiated from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >, _Compare = bool (*)(std::pair<int, int>&, std::pair<int, int>&)]'
PE.cpp:26:34:   instantiated from here
/usr/include/c++/4.6/bits/stl_algo.h:2233:4: error: invalid initialization of reference of type 'std::pair<int, int>&' from expression of type 'const std::pair<int, int>'
/usr/include/c++/4.6/bits/stl_algo.h:2236:4: error: invalid initialization of reference of type 'std::pair<int, int>&' from expression of type 'const std::pair<int, int>'