답안 #796643

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
796643 2023-07-28T15:10:52 Z Tunglam07 Ljeto (COCI21_ljeto) C++17
50 / 50
1 ms 316 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t, cnt[9],time,p1,p2,sc1=0,sc2=0, tbonus[9];
	for(int i=1;i<=9;i++)
	{
		tbonus[i] = INT_MAX;
	}
	for(int i=1;i<=9;i++)
	{
		cnt[i]=0;
	}
	cin >> t;
	for(int i=1;i<=t;i++)
	{
		cin >> time >> p1 >> p2;
		cnt[p1]++;
		if(p1>=1&&p1<=4)
		{
			sc1+=100;
			if(cnt[p1]>1&&i!=1)
			{
				if((time-tbonus[p1])<=10)
				{
					sc1+=50;
				}
			}
		}
		else
		{
			sc2+=100;
			if(cnt[p1]>1&&i!=1)
			{
				if(abs(time-tbonus[p1])<=10)
				{
					sc2+=50;
				}
			}
		}
		tbonus[p1]=time;
	}
	cout << sc1 << " " << sc2;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:12:13: warning: iteration 8 invokes undefined behavior [-Waggressive-loop-optimizations]
   12 |   tbonus[i] = INT_MAX;
      |             ^
Main.cpp:10:15: note: within this loop
   10 |  for(int i=1;i<=9;i++)
      |              ~^~~
Main.cpp:16:9: warning: iteration 8 invokes undefined behavior [-Waggressive-loop-optimizations]
   16 |   cnt[i]=0;
      |   ~~~~~~^~
Main.cpp:14:15: note: within this loop
   14 |  for(int i=1;i<=9;i++)
      |              ~^~~
Main.cpp:16:9: warning: 'void* __builtin_memset(void*, int, long unsigned int)' forming offset [36, 39] is out of the bounds [0, 36] of object 'cnt' with type 'int [9]' [-Warray-bounds]
   16 |   cnt[i]=0;
      |   ~~~~~~^~
Main.cpp:9:9: note: 'cnt' declared here
    9 |  int t, cnt[9],time,p1,p2,sc1=0,sc2=0, tbonus[9];
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct