Submission #674162

# Submission time Handle Problem Language Result Execution time Memory
674162 2022-12-23T10:55:32 Z Tangirkul Ljeto (COCI21_ljeto) C++17
50 / 50
1 ms 316 KB
#include<bits/stdc++.h>
  
#define ll long long
#define fi first
#define se second
#define pb push_back
#define sz size
#define Junanna ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  
using namespace std;
  
const ll K = 32;
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;
const ll N = (1e5 + 125);

void ma1n ()
{
    ll n;
    cin >> n;
    pair <ll, pair <ll, ll>> s[n + 7];
    ll last[10];
    for (ll i = 1; i <= 10; i++)
    {
        last[i] = 0;
    }
    for (ll i = 1; i <= n; i++)
    {
        cin >> s[i].fi >> s[i].se.fi >> s[i].se.se;
    }
    sort (s + 1, s + n + 1);
    ll b = 0, r = 0;
    for (ll i = 1; i <= n; i++)
    {
        if (last[s[i].se.fi] == 0)
        {
            if (s[i].se.fi <= 4)
            {
                b += 100;
            }
            else
            {
                r += 100;
            }
            last[s[i].se.fi] = s[i].fi;
        }
        else if (s[i].fi - last[s[i].se.fi] <= 10)
        {
            if (s[i].se.fi <= 4)
            {
                b += 150;
            }
            else
            {
                r += 150;
            }
            last[s[i].se.fi] = s[i].fi;
        }
        else
        {
            if (s[i].se.fi <= 4)
            {
                b += 100;
            }
            else
            {
                r += 100;
            }
            last[s[i].se.fi] = s[i].fi;
        }
    }
    cout << b << " " << r;
}
    
int main ()
{
    Junanna;
    ll t = 1;
    while (t--)
    {
        ma1n ();
    }
    return 0;
} 

Compilation message

Main.cpp: In function 'void ma1n()':
Main.cpp:25:17: warning: iteration 9 invokes undefined behavior [-Waggressive-loop-optimizations]
   25 |         last[i] = 0;
      |         ~~~~~~~~^~~
Main.cpp:23:22: note: within this loop
   23 |     for (ll i = 1; i <= 10; i++)
      |                    ~~^~~~~
Main.cpp:25:17: warning: 'void* __builtin_memset(void*, int, long unsigned int)' forming offset [80, 87] is out of the bounds [0, 80] of object 'last' with type 'long long int [10]' [-Warray-bounds]
   25 |         last[i] = 0;
      |         ~~~~~~~~^~~
Main.cpp:22:8: note: 'last' declared here
   22 |     ll last[10];
      |        ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct