Language: C++


//AOJ0099とほぼ同じ。座標圧縮がいらない。
//1位の見つけ方→1位が得点(順位そのまま),1位以外が得点(1位と得点したチームを比べる),1位以外が減点(順位そのまま),1位が減点(O(N)で1位を探す)
//欠点：最悪計算量O(N^2)
#include<iostream>
#define rep(j,n) for(j = 0;j < n;j++)
using namespace std;

int N,R,L;	//チーム数 <= 10^5,レコード数 <= 10^6,競技時間
int n[1000000],t[1000000],x[1000000];

int score[100000];
int time[100000];

int main(){
	int i,j;
	int num = 0;	//今最高得点の奴の番号
	cin >> N >> R >> L;
	rep(i,R){
		cin >> n[i] >> t[i] >> x[i];
		n[i]--;
	}
	time[0] = t[0];

	rep(i,R){
		//cout << "num = " << num << endl;
		score[ n[i] ] += x[i];
		//1位がそのまま
		if( (n[i] == num && x[i] >= 0) || (n[i] != num && x[i] <= 0) ){
			if(i < R-1)
				time[ num ] += t[i+1] - t[i];
			else
				time[ num ] += L - t[i];
			continue;
		}
		//1位と今のチームを比べる
		if( n[i] != num && x[i] >= 0 ){
			if( ( score[ num ] > score[ n[i] ] ) || ( score[ num ] == score[ n[i] ] && num < n[i] ) ){
			}
			else{
				num = n[i];
			}
			if(i < R-1)
				time[ num ] += t[i+1] - t[i];
			else
				time[ num ] += L - t[i];
			continue;
		}
		//1位を調べなおす
		for( j = 0; j < N; j++){
			if( ( score[ num ] > score[ j ] ) || ( score[ num ] == score[ j ] && num < j ) ){
			}
			else{
				num = j;
			}
		}
		if(i < R-1)
			time[ num ] += t[i+1] - t[i];
		else
			time[ num ] += L - t[i];
	}
	int MAX = 0,ANS = 0;
	for(j = 0;j < N;j++){
		if(MAX < time[j]){
			MAX = time[j];
			ANS = j;
		}
	}
	ANS++;
	cout << ANS << endl;
	return 0;
}

Compiler output:
a.cc:13:16: error: 'int time [100000]' redeclared as different kind of entity
   13 | int time[100000];
      |                ^
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:5:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
   76 | extern time_t time (time_t *__timer) __THROW;
      |               ^~~~
a.cc: In function 'int main()':
a.cc:23:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   23 |         time[0] = t[0];
      |               ^
a.cc:23:17: error: assignment of read-only location '* time'
   23 |         time[0] = t[0];
      |         ~~~~~~~~^~~~~~
a.cc:31:43: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   31 |                                 time[ num ] += t[i+1] - t[i];
      |                                           ^
a.cc:31:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   31 |                                 time[ num ] += t[i+1] - t[i];
      |                                 ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
a.cc:31:45: error: assignment of read-only location '*(time + ((sizetype)num))'
a.cc:33:43: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   33 |                                 time[ num ] += L - t[i];
      |                                           ^
a.cc:33:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   33 |                                 time[ num ] += L - t[i];
      |                                 ~~~~~~~~~~~~^~~~~~~~~~~
a.cc:33:45: error: assignment of read-only location '*(time + ((sizetype)num))'
a.cc:44:43: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   44 |                                 time[ num ] += t[i+1] - t[i];
      |                                           ^
a.cc:44:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   44 |                                 time[ num ] += t[i+1] - t[i];
      |                                 ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
a.cc:44:45: error: assignment of read-only location '*(time + ((sizetype)num))'
a.cc:46:43: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   46 |                                 time[ num ] += L - t[i];
      |                                           ^
a.cc:46:45: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   46 |                                 time[ num ] += L - t[i];
      |                                 ~~~~~~~~~~~~^~~~~~~~~~~
a.cc:46:45: error: assignment of read-only location '*(time + ((sizetype)num))'
a.cc:58:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   58 |                         time[ num ] += t[i+1] - t[i];
      |                                   ^
a.cc:58:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   58 |                         time[ num ] += t[i+1] - t[i];
      |                         ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
a.cc:58:37: error: assignment of read-only location '*(time + ((sizetype)num))'
a.cc:60:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   60 |                         time[ num ] += L - t[i];
      |                                   ^
a.cc:60:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   60 |                         time[ num ] += L - t[i];
      |                         ~~~~~~~~~~~~^~~~~~~~~~~
a.cc:60:37: error: assignment of read-only location '*(time + ((sizetype)num))'
a.cc:64:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   64 |                 if(MAX < time[j]){
      |                                ^
a.cc:64:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   64 |                 if(MAX < time[j]){
      |                    ~~~~^~~~~~~~~
a.cc:65:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   65 |                         MAX = time[j];
      |                                     ^
a.cc:65:37: error: invalid conversion from 'time_t (*)(time_t*) noexcept' {aka 'long int (*)(long int*) noexcept'} to 'int' [-fpermissive]
   65 |                         MAX = time[j];
      |                               ~~~~~~^
      |                                     |
      |                                     time_t (*)(time_t*) noexcept {aka long int (*)(long int*) noexcept}