結果
| 問題 | No.60 魔法少女 | 
| コンテスト | |
| ユーザー |  latte0119 | 
| 提出日時 | 2016-02-26 21:35:54 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 79 ms / 5,000 ms | 
| コード長 | 1,243 bytes | 
| コンパイル時間 | 1,319 ms | 
| コンパイル使用メモリ | 160,224 KB | 
| 実行使用メモリ | 8,800 KB | 
| 最終ジャッジ日時 | 2024-09-22 14:02:50 | 
| 合計ジャッジ時間 | 2,719 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 10 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |     scanf("%d%d",&N,&K);
      |     ~~~~~^~~~~~~~~~~~~~
main.cpp:30:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   30 |         scanf("%d%d%d",&X[i],&Y[i],&H[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:36:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |         scanf("%d%d%d%d%d",&x,&y,&w,&h,&d);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include<bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ln <<endl
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}
int N,K;
int X[100000],Y[100000],H[100000];
int sum[1010][1010];
signed main(){
    scanf("%d%d",&N,&K);
    rep(i,N){
        scanf("%d%d%d",&X[i],&Y[i],&H[i]);
        X[i]+=500;Y[i]+=500;
    }
    rep(i,K){
        int x,y,w,h,d;
        scanf("%d%d%d%d%d",&x,&y,&w,&h,&d);
        x+=500;y+=500;w++;h++;chmin(w,1001-x);chmin(h,1001-y);
        sum[x][y]+=d;
        sum[x+w][y]-=d;
        sum[x][y+h]-=d;
        sum[x+w][y+h]+=d;
    }
    rep(i,1001)reps(j,1,1001)sum[i][j]+=sum[i][j-1];
    reps(i,1,1001)rep(j,1001)sum[i][j]+=sum[i-1][j];
    int ans=0;
    rep(i,N)ans+=max(0,H[i]-sum[X[i]][Y[i]]);
    printf("%d\n",ans);
    return 0;
}
            
            
            
        