# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
597436 | KK_1729 | Tuna (COCI17_tuna) | C++14 | 1 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
// -------Macros---------
#define int long long
#define double long long double
#define pb push_back
#define str string
#define vi vector<int>
#define mp make_pair
#define mi map<int, int>
#define umi unordered_map<int, int>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define all(a) a.begin(), a.end()
#define endl "\n"
// ------------------------
// --------------------------Constants------------------------------
// const int INF = 1e17;
// const int MOD = 1e9+7;
// const int MOD2 = 998244353;
// const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;
// -------------------------------------------------------------------
// ----------------------Pre Written Functions---------------------------
int sum(vector<int> a){ // Returns the sum of values in a vector<int>
int total = 0;
for (int x : a) total += x;
return total;
}
template<typename T>
void printVector(T a){
for (auto x: a) cout << x << " ";
cout << endl;
}
template<typename T>
void printMap(T a){
cout << "{ ";
for (auto x: a){
cout << x.first << ": " << x.second << " ";
}
cout << "}" << endl;
}
int gcd(int a, int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
// Function to return LCM of two numbers
int lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
// ------------------------------------------------------------------------
// Main Code starts
void solve(){
int n; cin >> n;
int k; cin >> k;
int total_sum = 0;
while(n--){
int a, b; cin >> a >> b;
if (abs(a-b) > k){
int l; cin >> l;
total_sum += l;
}else{
total_sum += max(a, b);
}
}
cout << total_sum << endl;
}
int32_t main(){
// FastIO
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// int t; cin >> t;
int t = 1;
for (int tc = 1; tc <= t; ++tc){
// cout << "Case #" << tc << ": ";
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |