답안 #673558

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
673558 2022-12-21T05:03:57 Z Cookie Palembang Bridges (APIO15_bridge) C++14
0 / 100
1 ms 340 KB
#include<bits/stdc++.h>
#pragma GCC target("popcnt")
using namespace std;

 
#define ll long long
#define vt vector
#define pb push_back
#define fi first
#define se second
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
typedef unsigned long long ull;
#include<fstream>
ifstream fin("cowpatibility.in");
ofstream fout("cowpatibility.out");
#define pii pair<int, int>
#define pll pair<ll, ll>
const ll mod = 1e9 + 7, p =  1299709, mod2 = 1e9 + 9;
const int mxn = 1e5;
int k, n;
ll ans = 0;
vt<pll>v;
void solve1(){
    vt<ll>points;
    for(auto [aa, bb]: v){
        points.pb(aa); points.pb(bb);
    }
    sort(points.begin(), points.end());
    ll med = points[points.size() / 2];
    for(int i = 0; i < points.size(); i++){
        ans += abs(med - points[i]);
    }
    cout << ans;
    
}
void solve2(){
    
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> k >> n;
    forr(i, 0, n){
        char a, b; ll aa, bb;
        cin >> a >> aa >> b >> bb;
        if(a == b)ans += abs(aa - bb);
        else v.pb({aa, bb});
    }
    if(k == 1)solve1();
    else solve2();
    return 0;
}

Compilation message

bridge.cpp: In function 'void solve1()':
bridge.cpp:26:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   26 |     for(auto [aa, bb]: v){
      |              ^
bridge.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i = 0; i < points.size(); i++){
      |                    ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -