青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

O(1) 的小樂

Job Hunting

公告

記錄我的生活和工作。。。
<2010年9月>
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

統計

  • 隨筆 - 182
  • 文章 - 1
  • 評論 - 41
  • 引用 - 0

留言簿(10)

隨筆分類(70)

隨筆檔案(182)

文章檔案(1)

如影隨形

搜索

  •  

最新隨筆

最新評論

閱讀排行榜

評論排行榜

SRM 481

Div2

1 比較簡單的一道題目,理清楚邏輯關系。。

2 trick的一道題目,真是惡心人啊。。。從下面的一張圖中來看出種種的關系。。比賽的時候,糾結了。。所以沒搞出來。。

In the graphic, c + y will be equal to x (The total number of people that told you the correct answer) and a+b will be equal to n-x (The total number of people that told you the wrong answer). Since we know the number of elements in LIARS (liarCount) and the number of people in the intersection is assumed to be y we can conclude that a=lieCount-y. Similarly, b = liarCount-y. Since all the other literals are known, c = n - a - b - y. Knowing a, b, c and y we can verify: If (a+b) is equal to (n-x) and (c+y = x) then the scenario is possible. There is an implicit condition, an important one that was missed by many during the match, we do not want y to be so small, that the sum a+b-y is larger than n, this case can be detected by making sure that c is positive. Also note that since the numbers in the input can only be as large as 1000000, we can simply iterate through all the possible values of y until one for which the previous conditions hold.
We can then code a solution:

// Is the following scenario possible?:
//
// n people.
// x people told the truth.
// lieCount people were lied to.
// liarCount people lied intentionally
//
boolean check(int n, int x, int lieCount, int liarCount) {
    // Iterate through all the possible values of the intersection y:
    for (int y = 0; y <= lieCount && y <= liarCount; y++) {
        int a = lieCount - y;
        int b = liarCount - y;
        int c = n - a - b - y;

        // Do all the required conditions hold?
        if ( a+b==n-x && c+y==x && c>=0 ) {
            return true;
        }
    }
    return false;
}
//

public String theTruth(int n, int eggCount, int lieCount, int liarCount) {
    // Call the sub-routine, first assuming that the egg is the correct answer
    boolean egg =     check(n,eggCount, lieCount, liarCount );
    // Then assuming that the chicken is the correct answer:
    boolean chicken = check(n,n-eggCount, lieCount, liarCount );
    if(egg&&chicken) {
        return "Ambiguous";
    } else if (egg) {
        return "The egg";
    } else if (chicken) {
        return "The chicken";
    } else {
        return "The oracle is a lie";
    }
}
 

其中的邏輯關系還是很顯然的。。要淡定!。。。

QQ截圖未命名

看看某個房間里的情況。。唉,這告訴我們無論什么時候都不要放棄努力!

仔細和認真,有一個端正的態度是做好一切事情的法寶!

3 這個第三題應當和第二題換一下啊。。非常簡單。。

  因為一個人可能會有幾個job,但是一個job只能對應于一個人。。這就使問題變得非常簡單了。。很easy的會想到每個人的job duration和來做排序。。如果job duration 和相同,就以第一個首元素做排序標準。。

map <string,int> mp;
struct str{
       long long tot;
       int num;
       int next[55];
};
str st[55];
bool operator <(str a, str b)
{
     if (a.tot != b.tot)
        return a.tot < b.tot;
     return a.next[0] < b.next[0];
}
class BatchSystem
{
        public:
        vector <int> schedule(vector <int> duration, vector <string> user)
        {
               int n = duration.size();
               int i,j,t;
               int ct = 0;
               memset(st,0,sizeof(st));
               mp.clear();
               for (i = 0;i < n;i++)
               {
                   if (mp.find(user[i]) == mp.end())
                      mp[user[i]] = ct++;
                   t = mp[user[i]];
                   st[t].tot += duration[i];
                   st[t].next[st[t].num++] = i;
               }
               sort(st,st + ct);
               vector <int> ans;
               ans.clear();
               for (i = 0;i < ct;i++)
               {
                   for (j = 0;j < st[i].num;j++)
                       ans.push_back(st[i].next[j]);
               }
               return ans;
        }
};

剛開始的時候,以為這個題目中,一個job可以對應于幾個人的情況。。實在是不應該啊。。

 

 

 

===========================================================================================

不是很華麗的分割線。。。

===========================================================================================

DIV1

1 DIV2 500的題目,照例的惡心。。。

2 基于DIV900的那個理論,然后這次是求期望等待時間,需要分階段來討論。首先是在此人之前的人,其次是具有相同優先級的人,再次是這個人的不同工作之間。。總之,也是一個比較簡單的題目。

vector <double> expectedFinishTimes(vector <int> duration, vector <string> user)
{
    int n = duration.size();
    // Find users and their total durations:
    map<string, long long> userDuration;
    for (int i=0; i<n; i++) {
        userDuration[user[i]]+=duration[i];
    }
    vector<double> res(n);
    for (int i=0; i<n; i++) {
        int eqn = 0;
        double before = 0;
        // For each pair user, total duration:
        //   * count the number of users with the same
        //     total duration (eqn).
        //   * Accumulate the total duration from users
        //     with smaller total duration (before).
        for ( map<string,long long>::iterator it = userDuration.begin();
              it!=userDuration.end(); it++) {

            if (it->second < userDuration[user[i]] ) {
                before += it->second;
            } else if ( it->second == userDuration[user[i]] ) {
                eqn ++;
            }
        }
        // The time this process will have to wait is:
        //  before :
        //      The waiting time caused by users with lower total durations.
        // + (eqn-1) * userDuration[user[i]] / 2.0 :
        //      The expected waiting time caused by users with the same total duration.
        //
        // + (userDuration[user[i]]-duration[i]) / 2.0 :
        //      The expected waiting time caused by jobs from the same user.
        //
        // + duration[i]:
        //      The job's duration
        res[i] = before
                 + (eqn-1) * userDuration[user[i]] / 2.0
                 + (userDuration[user[i]]-duration[i]) / 2.0
                 + duration[i];
    }
    return res;
}
 
3 忘了什么意思了。。有時間貼出來。
Reference : 參考了SRM 481的解題報告和 best solution。。。代碼都是大大們寫的。。。學習!
 

posted on 2010-09-12 17:41 Sosi 閱讀(280) 評論(0)  編輯 收藏 引用

統計系統
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美精品国产精品| 99国产精品一区| 日韩午夜中文字幕| 欧美中文字幕不卡| 亚洲激情网站免费观看| 欧美先锋影音| 欧美精品在线免费播放| 免费在线观看成人av| 久久久久成人精品| 欧美激情bt| 欧美午夜电影一区| 欧美日韩 国产精品| 欧美成人精品三级在线观看| 久久久亚洲精品一区二区三区| aa国产精品| 亚洲欧美精品伊人久久| 国产日产欧美一区| 曰本成人黄色| 国产精品99久久久久久久久| 亚洲专区欧美专区| 老司机免费视频一区二区| 欧美国产日产韩国视频| 久久久久久久综合狠狠综合| 欧美成年人网站| 亚洲国产二区| 午夜影院日韩| 欧美亚洲日本一区| 亚洲国产精品久久人人爱蜜臀| 亚洲欧美日韩精品久久久| 久久先锋影音| 亚洲一区二区黄| 欧美激情精品久久久久久久变态| 欧美一区二区三区免费视| 久久这里有精品视频| 国产精品免费看片| 中日韩男男gay无套| 欧美77777| 欧美一区二区视频观看视频| 欧美色中文字幕| 久久精品在线播放| 国产伦精品一区二区三区四区免费| 亚洲电影在线| 久久亚洲精品中文字幕冲田杏梨| 夜夜爽av福利精品导航| 欧美日韩一区二区三区高清| 亚洲国产经典视频| 欧美成人四级电影| 久久国内精品自在自线400部| 欧美亚男人的天堂| 午夜亚洲激情| 亚洲免费网站| 国内揄拍国内精品少妇国语| 性欧美激情精品| 久久久久久久国产| 亚洲国产裸拍裸体视频在线观看乱了中文 | 欧美亚洲一区二区在线| 欧美激情在线免费观看| 亚洲三级网站| 亚洲综合99| 黄色日韩精品| 亚洲精品视频二区| 亚洲高清av| 欧美日韩一区国产| 久久久噜噜噜久久人人看| 欧美精品免费看| 欧美一区网站| 欧美日韩国产黄| 久久久久久久久蜜桃| 欧美日韩国产综合久久| 亚洲国产日韩欧美在线图片| 亚洲一级黄色片| 嫩模写真一区二区三区三州| 欧美黄色精品| 久久夜色精品国产欧美乱极品| 欧美国产成人在线| 久久本道综合色狠狠五月| 美女久久网站| 久久久免费精品视频| 国产精品国产自产拍高清av| 亚洲第一视频网站| 欧美777四色影视在线| 国产一区二区精品久久91| 亚洲欧美韩国| 久久福利一区| 国产日韩欧美不卡| 小处雏高清一区二区三区| 亚洲一区二区黄| 日韩亚洲综合在线| 亚洲免费av观看| 欧美理论在线| 亚洲一区二区在线免费观看视频| 99国产精品私拍| 国产精品久久久久永久免费观看| 亚洲另类春色国产| 亚洲一区网站| 国产亚洲精品美女| 免费成人高清在线视频| 欧美伊人久久久久久久久影院| 国产伦精品一区二区三区视频黑人 | 亚洲另类自拍| 久久久7777| 一区二区三区鲁丝不卡| 欧美一区二区在线免费播放| 狠狠久久婷婷| 欧美日韩中文字幕综合视频 | 久久久爽爽爽美女图片| 欧美色网在线| 免费久久99精品国产自| 99热精品在线观看| 久久综合色影院| 午夜精品久久久久久99热软件| 韩国av一区二区| 亚洲欧美日本国产专区一区| 欧美一区二区福利在线| 亚洲人成欧美中文字幕| 国产日本欧美一区二区三区| 欧美电影免费网站| 性高湖久久久久久久久| 亚洲精品永久免费| 亚洲电影免费观看高清| 久久久精品一区| 久久精品人人爽| 久久亚洲午夜电影| 久久亚洲欧美| 老司机凹凸av亚洲导航| 欧美在线国产精品| 亚洲黄色免费网站| 欧美国产大片| 欧美日韩人人澡狠狠躁视频| 一本色道久久综合亚洲精品按摩| 亚洲欧美中文日韩在线| 亚洲区一区二| 久久一区二区三区国产精品 | 欧美久久一区| 欧美第一黄网免费网站| 韩国精品在线观看| 欧美一区二区三区在线视频| 欧美一区二区三区四区在线| 国产精品成人国产乱一区| 亚洲麻豆国产自偷在线| 亚洲精品久久久久久久久| 欧美成人一区在线| 亚洲国产精品一区二区尤物区| 国产一区观看| 久久久久久免费| 欧美国产视频在线观看| 亚洲国产婷婷综合在线精品| 欧美激情第4页| 亚洲伦理在线观看| 亚洲综合日本| 国产日韩亚洲| 久久久www成人免费无遮挡大片| 久久午夜激情| 亚洲激情视频网站| 欧美美女操人视频| 亚洲亚洲精品在线观看| 久久久久久久久综合| 亚洲电影免费在线观看| 欧美激情中文字幕一区二区 | 久久久www成人免费无遮挡大片 | 国产亚洲电影| 久久午夜视频| 亚洲毛片在线| 久久aⅴ乱码一区二区三区| 黑丝一区二区| 欧美精品99| 午夜精品久久久久久久久| 在线日韩日本国产亚洲| 亚洲国产三级网| 99在线|亚洲一区二区| 一区二区三区高清视频在线观看 | 国产乱码精品一区二区三区av | 亚洲人体大胆视频| 欧美日本国产一区| 亚洲欧美在线视频观看| 欧美chengren| 香蕉精品999视频一区二区| 国产在线不卡| 欧美日韩国产精品一区二区亚洲| 欧美亚洲色图校园春色| 最新热久久免费视频| 欧美影院成人| 亚洲视频欧洲视频| 在线观看一区二区视频| 国产精品黄色| 欧美破处大片在线视频| 欧美中文字幕在线观看| 99国产精品视频免费观看一公开 | 欧美系列精品| 欧美顶级少妇做爰| 欧美一区二区在线视频| av成人免费在线观看| 欧美激情久久久| 美国三级日本三级久久99| 欧美激情一区二区在线 | 亚洲欧美日韩国产一区| 久久久99精品免费观看不卡| 亚洲精品久久久蜜桃| 国语自产精品视频在线看一大j8 | 欧美人与禽猛交乱配视频|