Submission #1110626

#TimeUsernameProblemLanguageResultExecution timeMemory
1110626vjudge1Tuna (COCI17_tuna)C++17
50 / 50
1 ms408 KiB

#include <bits/stdc++.h>
#define int long long
using namespace std;

int32_t main () {
	
	int n;
    
    int x;
    
    cin >>n;
    cin >>x;
    
    int h[n];
    int z[n];
    int b[n];
    
    int t=0;
    
    for(int i=0; i<n; i++)      {
    
    cin >> h[i];
    cin >> z[i];
    
    
    if(z[i] == h[i]) {
    
    t = t + z[i];
    
    }
    else if(z[i]>h[i]) {
    
       if(z[i] - h[i] > x) {
    
       cin >> b[i];
       t = t+b[i];
       
       }
       
       else {
       
       t = t + z[i];
       
       }
       
       }
       
       
          else {
    
       if(h[i] - z[i] > x) {
    
       cin >> b[i];
       t = t+b[i];
       
       }
       
       else {
       
       t = t + h[i];
       
       }
       
       }
       
       
       }
       
        cout << t <<endl;
                 
      return 0;
       }
#Verdict Execution timeMemoryGrader output
Fetching results...