提出 #922581


ソースコード 拡げる

/* ***********************************************
Author        :guanjun
Created Time  :2016/10/11 14:54:59
File Name     :1.cpp
************************************************ */
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
	int x,y;
};
struct cmp{
    bool operator()(Node a,Node b){
        if(a.x==b.x) return a.y> b.y;
        return a.x>b.x;
	}
};

bool cmp(int a,int b){
    return a>b;
}
typedef pair<ll,int> pii;
vector<pii>v;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    #endif
    //freopen("out.txt","w",stdout);
    ll h,w,x;
	while(scanf("%lld %lld",&w,&h)!=EOF){
		v.clear();
		for(int i=0;i<w;i++){
			scanf("%lld",&x);
			v.push_back({x,0});
		}
		for(int i=0;i<h;i++){
			scanf("%lld",&x);
			v.push_back({x,1});
		}
		sort(v.begin(),v.end());
		ll ans=0;
		w++;
		h++;
		for(int i=0;i<v.size();i++){
			if(v[i].second==1){
				ans+=w*v[i].first;
				h--;
			}
			else {
				ans+=h*v[i].first;
				w--;
			}
		}
		printf("%lld\n",ans);
	}
    return 0;
}

提出情報

提出日時
問題 C - Gr-idian MST
ユーザ guanjun
言語 C++14 (GCC 5.4.1)
得点 500
コード長 1335 Byte
結果 AC
実行時間 52 ms
メモリ 4464 KiB

コンパイルエラー

./Main.cpp: In function ‘int main()’:
./Main.cpp:42:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld",&x);
                    ^
./Main.cpp:46:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld",&x);
                    ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 2
AC × 30
セット名 テストケース
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, s1.txt, s2.txt
ケース名 結果 実行時間 メモリ
01.txt AC 48 ms 4464 KiB
02.txt AC 48 ms 4464 KiB
03.txt AC 48 ms 4464 KiB
04.txt AC 48 ms 4464 KiB
05.txt AC 48 ms 4464 KiB
06.txt AC 48 ms 4464 KiB
07.txt AC 48 ms 4464 KiB
08.txt AC 48 ms 4464 KiB
09.txt AC 48 ms 4464 KiB
10.txt AC 48 ms 4464 KiB
11.txt AC 46 ms 4464 KiB
12.txt AC 47 ms 4464 KiB
13.txt AC 52 ms 4464 KiB
14.txt AC 47 ms 4464 KiB
15.txt AC 47 ms 4464 KiB
16.txt AC 25 ms 2420 KiB
17.txt AC 25 ms 2420 KiB
18.txt AC 25 ms 2420 KiB
19.txt AC 24 ms 2420 KiB
20.txt AC 30 ms 4464 KiB
21.txt AC 38 ms 4464 KiB
22.txt AC 38 ms 4464 KiB
23.txt AC 49 ms 4464 KiB
24.txt AC 38 ms 4464 KiB
25.txt AC 3 ms 256 KiB
26.txt AC 2 ms 256 KiB
27.txt AC 2 ms 256 KiB
28.txt AC 3 ms 256 KiB
s1.txt AC 3 ms 256 KiB
s2.txt AC 3 ms 256 KiB