A1054 The Dominant Color
題目很簡單,用map省空間,如果直接開很大的陣列統計數字出現次數,不知道會不會爆記憶體,畢竟數字到了2^24.
沒必要開二維陣列,反正空間都是m*n。
#include <stdio.h>
#include <map>
using namespace std;
int main(int argc, char const *argv[])
{
int m,n;
scanf("%d%d",&m,&n);
int color;
map<int,int> mp;
for(int i=0;i<m*n;i++){
scanf ("%d",&color);
mp[color]++;
}
for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
if(it->second > m*n/2){
printf("%d",it->first);
break;
}
}
return 0;
}
相關推薦
A1054 The Dominant Color
題目很簡單,用map省空間,如果直接開很大的陣列統計數字出現次數,不知道會不會爆記憶體,畢竟數字到了2^24. 沒必要開二維陣列,反正空間都是m*n。 #include <stdio.h> #include <map> using namespace std;
PAT-ADVANCED1054——The Dominant Color
我的PAT-ADVANCED程式碼倉:https://github.com/617076674/PAT-ADVANCED 原題連結:https://pintia.cn/problem-sets/994805342720868352/problems/994805422639136768
PAT 1054 The Dominant Color (20 分)
1054 The Dominant Color (20 分) Behind the scenes in the computer’s memory, color is always talked about as a series of 24 bits of information fo
PAT (Advanced Level) Practice 1054 The Dominant Color (20 分) map使用
Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color
1054 The Dominant Color (20 分)
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for ea
The Dominant Color (20)
The Dominant Color (20) 時間限制 1000 ms 記憶體限制 65536 KB 程式碼長度限制 100 KB 判斷程式 Standard (來自 小小) 題目描述 Beh
1054 The Dominant Color(map 以及 STL的應用)
1054 The Dominant Color (20 分) Behind the scenes in the computer’s memory, color is always talked about as a series of 24 bits of i
PAT 甲級 1054 The Dominant Color (20 分)
1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of in
【PAT】1054. The Dominant Color (20)
題目描述 Behind the scenes in the computer’s memory, color is always talked about as a series of 24 bits of information for each pixel
PAT1054 The Dominant Color
Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image
1054 The Dominant [email protected]
Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of i
HDU-1556 Color the ball 【差分數組】
前綴 思想 bsp 前綴和 一個 sizeof all 屬於 pri Problem Description N個氣球排成一排,從左到右依次編號為1,2,3....N.每次給定2個整數a b(a <= b),lele便為騎上他的“小飛鴿"牌電動車從氣球a開始到氣球b
Color the ball 線段樹 區間更新但點查詢
查詢 main rst cst con time ear rtu ani #include<iostream> #include<cstdio> #include<cmath> #include<cstring> #inc
【hdu1556】Color the ball——樹狀數組
can n) 實現 分享 ... 2個 tput ring font Problem Description N個氣球排成一排,從左到右依次編號為1,2,3....N.每次給定2個整數a b(a <= b),lele便為騎上他的“小飛鴿"牌電動車從氣球a開始到氣球b依
線段樹(求單結點) hdu 1556 Color the ball
inpu int namespace bmi define != tle ring desc Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java
hdu1556 Color the ball
cout memset col turn tree () lazy 線段樹 amp 思路: 線段樹區間更新模板。 實現: 1 #include <bits/stdc++.h> 2 using namespace std; 3 const int N =
【貪心】Codeforces 349B.Color the Fence題解
結果 感到 left ret 題解 方法 main 這也 ++ 題目鏈接:http://codeforces.com/problemset/problem/349/B 題目大意 小明要從9個數字(1,2,……,9)去除一些數字拼接成一個數字,是的這個數字最大。 但是小明每取
hdu 1556 Color the ball(線段樹區間維護+單點求值)
code AR else map 區間維護 strong ssi 求值 blank 傳送門:Color the ball Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768
HDU - 1556 - Color the ball( 序列的區間操作 )
tom scanf bmi nbsp content 測試 序列 java sin Color the ball Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe
Color the ball HDU - 1556 (非線段樹做法)
不同 clu n) color hdu style str () span 題意:在1到n的氣球中,在不同的區域中塗顏色,問每個氣球塗幾次。 #include<cstdio>int num[100010];int main(){ int n, x, y;; wh