Submission #596990

# Submission time Handle Problem Language Result Execution time Memory
596990 2022-07-15T11:11:19 Z f1nder Tuna (COCI17_tuna) C++17
0 / 50
2 ms 340 KB
#include<bits/stdc++.h>
using namespace std;
void solve();
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);
 
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("error.txt", "w", stderr);
   freopen("output.txt", "w", stdout);
   #endif
   
int t=1;
while(t--)
{
	solve();
	cout<<"\n";
}

cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
return 0;
}
void solve()
{
    int n,k;cin>>n>>k;
    int ans=0;
    for (int i = 0; i < n; i++) {
        /* code */
        int h,j;cin>>h>>j;
        if(abs(h-j)<=k) ans+=max(h,j);
        else{
            int l;cin>>l;
            ans+=l;
        }
    }
    cout<<ans;
}	

Compilation message

tuna.cpp: In function 'int main()':
tuna.cpp:9:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |    freopen("input.txt", "r", stdin);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
tuna.cpp:10:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |    freopen("error.txt", "w", stderr);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
tuna.cpp:11:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |    freopen("output.txt", "w", stdout);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -