Submission #796643

#TimeUsernameProblemLanguageResultExecution timeMemory
796643Tunglam07Ljeto (COCI21_ljeto)C++17
50 / 50
1 ms316 KiB
#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 (stderr)

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];
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...