Submission #1110629

# Submission time Handle Problem Language Result Execution time Memory
1110629 2024-11-10T06:25:53 Z vjudge1 Tuna (COCI17_tuna) C++17
50 / 50
1 ms 508 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,i;
    cin>>n>>i;
    int dan;
    int topl=0;
    int h[n], z[n];
    for(int j; j<n; j++){
        cin>>h[j]>>z[j];
        if(h[j]>z[j]){
            if(h[j]-z[j]<=i) topl+=h[j];
            else{
                cin>>dan; topl+=dan;
            }
        }
        else{
            if(z[j]-h[j]<=i) topl+=z[j];
            else{
                cin>>dan; topl+=dan;
            }
        }
    }
    cout<<topl;
}

Compilation message

tuna.cpp: In function 'int main()':
tuna.cpp:11:13: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   11 |     for(int j; j<n; j++){
      |             ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 508 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct